fix(test-utils): cancel subprocess tracking timer for every proc in afterEach

The vitest subprocess guard's 60 s tracking timer could outlive the test
that spawned it and fire during a later test's afterEach, producing
spurious "Timed out after 60000ms" failures attributed to a different
test name under concurrent recursive test load.

Scope "Left running" reporting + SIGKILL to the current test's procs but
always clear each tracked subprocess's timer so it cannot fire later.
Bump the post-test grace from 200 ms to 1 s to absorb event-loop
contention from slow git shells.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-22 18:38:51 -07:00
parent d37bebf8bf
commit ec6643e4d9
2 changed files with 40 additions and 8 deletions

View File

@@ -0,0 +1,19 @@
---
"@fusion/core": patch
---
fix(test-utils): cancel subprocess tracking timer for every proc in afterEach
The vitest subprocess guard registered a 60 s "command timed out" timer for
each tracked child process and relied on `afterEach` to cancel it. Under
concurrent load (`pnpm` recursive test runs) the timer could outlive the
originating test and fire during a later test's `afterEach`, surfacing as
spurious "Test subprocess guard detected unsafe child-process usage:
Timed out after 60000ms" failures attributed to a different test name.
The cleanup loop now scopes "Left running" failure reporting + SIGKILL to
processes spawned by the current test, but unconditionally clears each
tracked subprocess's timer so the 60 s timeout cannot fire after the
afterEach completes. The grace period before declaring a process leaked
is also raised from 200 ms to 1 s to absorb event-loop contention from
slow git shells under recursive test load.