Repository navigation
test(daemon-client): join a client call that outlives its case - #4896
Conversation
The file shares one module-level launch mock, and afterEach reset it while a slow case was still driving its client call. Vitest rejects a test at its timeout and never cancels the body, so that call kept running while the next case was already going: it consumed a step of the next case's launch plan and recorded its spawns against it, which is how one timed-out case failed the case after it. Register every sendToDaemon and ensureDaemon call, and have afterEach join the calls that outlived their case before it resets the shared seams or tears the fixtures down. A call that outlasts the join is reported once, by the case that owns it, and every reset still runs: a half-reset is the state that caused the cascade. Two cases cover the crossing, one leaving a call in flight and the next asserting the launch seam stays untouched while it runs.
Size Report
Startup median (7 runs, lower is better):
|
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
The code looks ready at 927342f: the join closes the leak from a client call that outlives its case, and no problems were found in the diff. There are no conflicts, and CI is green: the three cancelled Body rules runs were replaced by newer runs, and the latest one passes. One other check is still running, and the diff is one test file with no production code, so it touches no failing job. Not verified here: the tests were not run for this review, the 20-run, sibling-file and mutation results are the author's own, and vitest's afterEach hook order and hook timeout behavior under a loaded runner were not checked. Not blocking, and fine to take or leave: the second new case waits a fixed 1.2 s of real time (line 872), so it could gate the second start on a promise the test releases; the two new cases depend on their order (line 857); the afterEach scaffolding at line 117 could be two hooks once the hook order is confirmed; and the PR body says "Fixes #4848" although that issue also asks for the two timing tests to stop waiting real time, so "Refs" or an amended issue would fit better. Nothing else is needed before merge, apart from the outstanding check. |
Summary
daemon-client-ensure-explicit-lifecycle.test.tsshares one module-level launch mock, andafterEachreset it while a slow case was still driving its client call. Vitest rejects a test at its timeout and never cancels the body, so that call kept running while the next case was already going: it spent a step of the next case's launch plan and recorded its spawns against it. One timed-out case failed the case after it (#4848).Every
sendToDaemonandensureDaemoncall is registered now, andafterEachjoins the calls that outlived their case before it resets the shared seams or tears the fixtures down. A call that outlasts the join is reported once, by the case that owns it, and every reset still runs: a half-reset is the state that caused the cascade. No timeout is raised and no assertion is weakened. Two cases cover the crossing: one leaves a call in flight, the next asserts the launch seam stays untouched while it runs.No production code changes.
Before / after
Base, with only the join removed:
Head:
Validation
At head
927342f615: the focused file, 20 consecutive runs green, then 70 runs with ten files in parallel on a 12-core host, 0 failures; sibling files sharing those fixtures, 34 passed;daemon-fixture-launch-guardandtest/repo-guards, 198 passed.tsc -b,oxlintandoxfmtpass. CI is green and its slow-test report names no entry from this file. Not device-facing.Fixes #4848
🤖 Generated with Claude Code