fix(executor): terminate abandoned execution trees - #1009
Open
stgmt wants to merge 2 commits into
Open
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
…hrough MCP handlers
Commit 83aefee added AbortSignal plumbing and an ownership sidecar, but the
signal never reached the executor on the public MCP path: wrapToolHandler
dropped the SDK's (args, extra) second argument, so every handler saw
extra === {} and no host cancellation could arrive; ctx_execute_file never
forwarded a signal at all. Also fixed two abort hangs: pre-aborted signals
now short-circuit before spawn, and a post-kill grace timer settles the
execution instead of waiting indefinitely for `close` (inherited stdio
handles on Windows can delay it far past the kill).
- server.ts: wrapToolHandler forwards extra (request-scoped AbortSignal);
ctx_execute_file forwards signal to executeFile
- executor.ts: pre-abort fast path; ABORT_SETTLE_GRACE_MS deterministic
settle with listener/stream cleanup; abortSettleTimer cleared on
close/error
- tests/executor.test.ts: regression suite - shell tree (child+grandchild)
killed on abort with <5s settlement and .ctx-mode-* temp cleanup;
ownership.json is metadata-only (canary: no command/code/secrets) and
removed; pre-abort never spawns; abort is request-scoped (concurrent and
fresh executions unaffected); timeout path green with inert signal;
executeFile forwards signal
- README.md: document host-driven cancellation and the sidecar contract
Tests: 127 passed | 25 platform-skipped (vitest tests/executor.test.ts);
tsc --noEmit green.
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ctx_executeandctx_execute_file.ctx-mode-*sandboxes and add metadata-only ownership manifests for safe recoveryRegression
A disconnected/abandoned
ctx_executerequest could leavebash -c .../.ctx-mode-*/scriptand its Python descendants running indefinitely. One observed tree consumed CPU continuously for five days.Verification
tests/executor.test.ts: 127 passed, 25 platform-specific skippedtsc --noEmit: passed🤖 Generated with Claude Code