Abort kills the command on the worker (#8 follow-up)

- worker: commands run with spawn in their own process group (same
  timeout, 10 MB output limit and result fields as exec). A new
  cancel_command message (by command_id, or every command of an
  execution) sends SIGTERM to the group, then SIGKILL after 5 s; the
  result reports cancelled: true. Old workers ignore the message.
- server: the abort route sends cancel_command to the worker running each
  of the execution's commands.
- Tests: the whole process tree dies on cancel (a background child too),
  execution-wide cancel leaves other executions alone, and end to end an
  aborted quick command's process is gone from the worker. Liveness
  checks treat zombies as dead (an orphan waits to be reaped).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-22 23:59:50 -05:00
1 parent dc732a1ec5
commit 073114c92e
4 files changed
+164 -46

No files matched your search

+7 -2
View File
@@ -1725,9 +1725,14 @@ app.post('/api/executions/:id/abort', authenticateSSO, async (req, res) => {
// Update execution status to failed
await updateExecutionStatus(executionId, 'failed');
// Stop tracking its direct command so the result timeout doesn't fire later
// Kill its commands on the workers (#8), and stop tracking them so their result
// timeouts don't fire later. A worker that predates cancel_command ignores it.
for (const [key, t] of _commandTargets) {
if (t.direct && t.executionId === executionId) {
if (t.executionId !== executionId) continue;
if (t.ws && t.ws.readyState === WebSocket.OPEN) {
t.ws.send(JSON.stringify({ type: 'cancel_command', execution_id: executionId, command_id: key }));
}
if (t.direct) {
clearTimeout(t.timer);
_commandTargets.delete(key);
}