Skip to content

test(daemon-client): join a client call that outlives its case - #4896

Merged
thymikee merged 1 commit into
mainfrom
t3/fix-daemon-client-lifecycle-timeouts
Nov 21, 2026
Merged

thymikee merged 1 commit into
mainfrom
t3/fix-daemon-client-lifecycle-timeouts

Conversation

@thymikee

@thymikee thymikee commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

daemon-client-ensure-explicit-lifecycle.test.ts 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 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 sendToDaemon and ensureDaemon call is registered now, and afterEach joins 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:

x the call that outlived the case before this one records no launch here 119990ms
  -> no daemon launch may be recorded during this case
Tests  1 failed | 25 passed (26)

Head:

Tests  26 passed (26)

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-guard and test/repo-guards, 198 passed. tsc -b, oxlint and oxfmt pass. CI is green and its slow-test report names no entry from this file. Not device-facing.

Fixes #4848

🤖 Generated with Claude Code

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.
@github-actions

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.48 MB 6.48 MB +403 B
Package (unpacked) 6.48 MB 6.48 MB +403 B
Package (download) 1.97 MB 1.97 MB +265 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 17.4 ms 17.2 ms -0.2 ms
CLI --help 36.3 ms 36.0 ms -0.4 ms

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 927342f

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (55be96bb6018).

💬 Talking to Sentinel

In a finding's thread, reply with:

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.

@thymikee

Copy link
Copy Markdown
Member Author

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.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 21, 2026
@thymikee
thymikee merged commit be18beb into main Nov 21, 2026
22 of 26 checks passed
@thymikee
thymikee deleted the t3/fix-daemon-client-lifecycle-timeouts branch November 21, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: daemon-client explicit-lifecycle tests time out near the 5 s limit and cascade

1 participant