fix(agent-jobs): stop heartbeat from resurrecting terminated jobs
This commit is contained in:
@@ -1223,6 +1223,7 @@ export const recoverStaleJobs = internalMutation({
|
||||
const now = Date.now();
|
||||
await ctx.db.patch(job._id, {
|
||||
status: 'timed_out',
|
||||
workspaceStatus: 'expired',
|
||||
error:
|
||||
job.error ??
|
||||
'The worker stopped reporting progress; the job timed out.',
|
||||
@@ -1512,12 +1513,15 @@ export const heartbeatWorkspace = mutation({
|
||||
if (job?.claimedBy !== args.workerId) {
|
||||
throw new ConvexError('Agent job not claimed by this worker.');
|
||||
}
|
||||
if (isTerminalStatus(job.status)) {
|
||||
return { success: true, cancelRequested: true };
|
||||
}
|
||||
await ctx.db.patch(args.jobId, {
|
||||
workspaceStatus: 'active',
|
||||
lastHeartbeatAt: Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
});
|
||||
return { success: true, cancelRequested: job.status === 'cancelled' };
|
||||
return { success: true, cancelRequested: false };
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user