fix: race condition + frontend refetching

This commit is contained in:
Julian Sommer
2026-02-27 08:14:50 +10:00
parent 12c2e2789e
commit 992111e809
4 changed files with 18 additions and 6 deletions
+5
View File
@@ -51,6 +51,11 @@ func (d *Daemon) handleEC2RunInstances(msg *nats.Msg) {
respondWithError(msg, awserrors.ErrorMissingParameter)
return
}
if d.imageService == nil {
slog.Error("handleEC2RunInstances image service not initialized")
respondWithError(msg, awserrors.ErrorServerInternal)
return
}
if _, err := d.imageService.GetAMIConfig(*runInstancesInput.ImageId); err != nil {
slog.Error("handleEC2RunInstances AMI not found", "imageId", *runInstancesInput.ImageId, "err", err)
respondWithError(msg, awserrors.ErrorInvalidAMIIDNotFound)
+2 -2
View File
@@ -224,8 +224,8 @@ func TestHandleEC2RunInstances_MessageParsing(t *testing.T) {
// Start test NATS server
natsURL := sharedNATSURL
// Create test daemon
daemon := createTestDaemon(t, natsURL)
// Create test daemon with all services initialized (image, key, etc.)
daemon := createFullTestDaemon(t, natsURL)
// Subscribe to the ec2.launch topic with the handler
sub, err := daemon.natsConn.QueueSubscribe("ec2.launch", "hive-workers", daemon.handleEC2RunInstances)
File diff suppressed because one or more lines are too long
@@ -29,6 +29,7 @@ export const ec2InstancesQueryOptions = queryOptions({
const command = new DescribeInstancesCommand({})
return getEc2Client().send(command)
},
refetchInterval: 5000,
})
export const ec2InstanceQueryOptions = (instanceId: string) =>
@@ -40,6 +41,7 @@ export const ec2InstanceQueryOptions = (instanceId: string) =>
})
return getEc2Client().send(command)
},
refetchInterval: 5000,
})
export const ec2InstanceTypesQueryOptions = queryOptions({
@@ -55,6 +57,7 @@ export const ec2InstanceTypesQueryOptions = queryOptions({
})
return getEc2Client().send(command)
},
refetchInterval: 5000,
})
export const ec2ImagesQueryOptions = queryOptions({
@@ -132,6 +135,7 @@ export const ec2SnapshotsQueryOptions = queryOptions({
const command = new DescribeSnapshotsCommand({})
return getEc2Client().send(command)
},
refetchInterval: 5000,
})
export const ec2SnapshotQueryOptions = (snapshotId: string) =>
@@ -143,6 +147,7 @@ export const ec2SnapshotQueryOptions = (snapshotId: string) =>
})
return getEc2Client().send(command)
},
refetchInterval: 5000,
})
export const ec2VpcsQueryOptions = queryOptions({
@@ -170,6 +175,7 @@ export const ec2VolumesQueryOptions = queryOptions({
const command = new DescribeVolumesCommand({})
return getEc2Client().send(command)
},
refetchInterval: 5000,
})
export const ec2VolumeQueryOptions = (volumeId: string) =>
@@ -181,4 +187,5 @@ export const ec2VolumeQueryOptions = (volumeId: string) =>
})
return getEc2Client().send(command)
},
refetchInterval: 5000,
})