Repository navigation
fix(test): kill process group on teardown to prevent stale web-client leak (#918 fix) - #1231
bassilkhilo-ag2 wants to merge 1 commit into
Conversation
VasiliyRad
left a comment
There was a problem hiding this comment.
Eighth PR this session with the same 4-file bundle (build_log.md, health-check.py, health-check-bridge-multi-pid.test.py, sync-memory-memory-dir.test.sh). Real change is the 16/-6 in tests/agent-state-endpoint.test.ts. Strip the bundle; the base branch your PRs are forked from still carries those un-pushed pass-207 changes. Pattern flagged on #1196/#1194/#1225/#1226/#1227/#1228/#1229; #1230 was closed appropriately after you saw the dup-src feedback — please apply the same fix here.
380d1de to
d7e42fe
Compare
|
Rebased onto |
|
Branch is now clean — only |
…ver leaks `npx tsx` spawns a multi-process chain: npm → tsx → node. The previous teardown sent SIGTERM/SIGKILL only to the direct child (npm), leaving the actual tsx/node web-client processes alive with the port bound. On the next test run, the `before()` hook polls the port and immediately gets 200 from the stale server instead of the newly spawned one. The stale server has a deleted temp workspace → core-status.json ENOENT → stale:true → tmux scrape sees sutando-core active → effectiveAgentState() returns 'working' for every test regardless of track state. Fix: spawn with `detached: true` (new process group) and kill `-child.pid` (the group) instead of `child.pid` in teardown, so all descendants die together. Also updates the `after()` guard to `child?.pid` for safety. Resolves the 6 consistent test failures that were introduced when the test's previous run left stale PID processes holding port 18081. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d7e42fe to
05fc05c
Compare
|
Rebased on clean |
|
Closing per owner instruction — autonomous PR creation halted. |
Root cause
npx tsxspawns a multi-process chain: npm → tsx → node. The previous teardown sentSIGTERM/SIGKILLonly to the direct child (npm exec), leaving the actualtsx/nodeweb-client processes alive — still holding the test port (18081).On the next test run:
before()polls the port → gets 200 from the stale server instead of the newly spawned onecore-status.jsonENOENT →stale: true→ tmux scrape seessutando-coreactive →effectiveAgentState()returns'working'for every requestactual: 'working', regardless of track resets inbeforeEachThis explains the 6 consistent failures that appeared to be unrelated to recent changes — they only fail when a previous test run's teardown leaked the server process.
Fix
detached: true→ creates a new process group for the entire npm→tsx→node subtreeprocess.kill(-child.pid!, signal)(negative PID = send to process group) so all descendants die togetherchild?.pidfor null safetyTest
See also
{"state":"working","label":"Bash"}regardless of/mute-state?state=idleresetsworkingwhen workspace temp dir is deleted🤖 Generated with Claude Code