Repository navigation
fix(test): reap the CLI e2e children when a test times out - #80
Merged
Merged
Conversation
The e2e harness spawned the CLI with plain `spawn` and never killed it. A REPL child blocks on stdin and the MCP server it starts is a grandchild, so a test that timed out — or a vitest worker torn down mid-run — left the whole chain reparented to systemd and hanging indefinitely. Seven such chains sat for 7h45m before anyone noticed, still holding their `/tmp/agent-e2e-*` directories. Spawn into a process group (`detached`) and kill the group in `afterEach`, and again on worker exit, so a failure cleans up after itself. The group is what matters: killing the CLI alone would have left its MCP server orphaned. Verified by adding a REPL test that never answers its marker — it times out at 5s and leaves no process and no temp directory behind — then removing it.
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.
Problem
src/cli.e2e.test.tsspawned the CLI with plainspawnand never reaped it. A REPL child blocks on stdin and the MCP server it starts is a grandchild, so a test that timed out (or a vitest worker torn down mid-run) left the whole chain reparented tosystemd --userand hanging.Seven such chains sat for 7h45m on this machine before anyone noticed, still holding their
/tmp/agent-e2e-*directories open.Fix
spawnClispawnsdetached: true, so the child leads its own process group.killTreekills the group (process.kill(-pid)), which takes the MCP server with it — killing the CLI alone would orphan the server.afterEachkills anything still running;process.on("exit")is the belt-and-braces for a worker that never reaches the hook.Verification
/tmp/agent-e2e-*left.