Skip to content

Commit 4adbb61

Browse files
author
John Fawcett
committed
fix(gastown): check dispatchAgent return value instead of using .catch()
dispatchAgent resolves false (never rejects) on container start failure, so the .catch() handler was dead code. Changed to check the boolean return value so the idle rollback actually executes on failure.
1 parent 9d1af68 commit 4adbb61

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

cloudflare-gastown/src/dos/town/actions.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -558,17 +558,19 @@ export function applyAction(ctx: ApplyActionContext, action: Action): (() => Pro
558558

559559
const capturedAgentId = agentId;
560560
return async () => {
561-
// Best-effort dispatch. On failure, roll the agent back to 'idle'
562-
// immediately so the reconciler can retry dispatch on the next tick
563-
// without waiting for heartbeat timeout (90s). The bead stays
564-
// 'in_progress' so it remains eligible for re-dispatch. (§5.4)
565-
await ctx.dispatchAgent(capturedAgentId, beadId, rigId).catch(err => {
561+
// Best-effort dispatch. dispatchAgent resolves false (never rejects)
562+
// on failure, so we check the return value. On failure, roll the
563+
// agent back to 'idle' immediately so the reconciler can retry
564+
// dispatch on the next tick without waiting for heartbeat timeout
565+
// (90s). The bead stays 'in_progress' so it remains eligible for
566+
// re-dispatch. (§5.4)
567+
const started = await ctx.dispatchAgent(capturedAgentId, beadId, rigId);
568+
if (!started) {
566569
console.warn(
567-
`${LOG} dispatch_agent: container start failed for agent=${capturedAgentId} bead=${beadId}, rolling back to idle`,
568-
err
570+
`${LOG} dispatch_agent: container start failed for agent=${capturedAgentId} bead=${beadId}, rolling back to idle`
569571
);
570572
agentOps.updateAgentStatus(sql, capturedAgentId, 'idle');
571-
});
573+
}
572574
};
573575
}
574576

0 commit comments

Comments
 (0)