Repository navigation
Description
Problem
packages/stim-cli/src/__tests__/stimd.integration.test.ts > stimd > "a CI hold keeps a quiescent persistent daemon alive through off mode" fails intermittently on ci / test (macos) only. It has blocked #5575, #5583, #5611, #5613 and #5576.
Since #5612 it fails at the last assertion, expect(existsSync(stimdRecordFile())).toBe(false) (line 412): AssertionError: expected true to be false. Before #5612 it failed in the hold with Could not pin the Stim daemon for this CI job.
Evidence
- feat: the worker-side test capability, approved only by stim setup --test #5576 head 40abe0b (contains fix: a command continues across a stimd restart, and a CI hold survives an exiting stimd #5612), run 43358163612, job 131686027728: the test took 7609 ms and failed at line 412. The assertions at lines 404 and 407 passed.
- fix: stimd records every exit, keeps its crash history and logs a handover with no successor #5583 head 64f6732, job 131523420253: 3.9 s,
Could not pin the Stim daemon for this CI job.fromholdExistingStimd. - A passing macOS run of the same test (fix: a command continues across a stimd restart, and a CI hold survives an exiting stimd #5612, job 131646895282) took 4478 ms. The failing run took about 3.1 s longer, which is about one idle exit plus one stimd started from source.
- The CI log shows no test stderr, so it cannot show whether
holdExistingStimdprinted anything. The fix: stimd keeps device log streams across a crash, a planned update and a logs worker failure #5575 diagnostic on main prints only when the hold throws, and since fix: a command continues across a stimd restart, and a CI hold survives an exiting stimd #5612 it does not throw. - The failure does not reproduce on an idle Mac (30 of 30), or with 40 CPU burners (12 of 12).
Cause
The test starts stimd in-process with runStimd({ mode: 'on', tickMs: 500 }). It then assumes that holdCIStimd pins that stimd, but nothing in the test makes that true.
- A persistent stimd with nothing running exits after two empty ticks (
packages/stim-cli/src/stimd/main.tslines 1731 to 1753,EMPTY_TICKS_BEFORE_EXIT = 2). After the first empty tick it waitsslowTickMs(2.5 s) only when memory and disk pressure are normal; otherwise it waitstickMs(500 ms) (line 1675). The test does not normalise the measurement, unlike "exits after two ticks with nothing running" in the same file, so on a macOS runner the stimd can exit about 1 s after it starts. - The hold reaches stimd only after a cold dynamic import of
api/client.ts(api.tsholdCIStimd). On a slow runner that can take longer than the idle exit. - When the stimd has already shut down, the hold's first pin fails. Since fix: a command continues across a stimd restart, and a CI hold survives an exiting stimd #5612,
holdExistingStimdthen replaces it (packages/stim-cli/src/daemon/client.tslines 1567 to 1571 and 1603):ensureStimdspawns a separate stimd process, and the hold pins that one. This is the specified behavior. - The test then passes lines 404 and 407, because the record it checks belongs to the replacement. After
releaseHold(),await runningreturns at once, because the in-process stimd ended long before. The replacement still runs and still ownsstimd.json, so line 412 fails.shutdownremoves the record only when it holds its own pid (main.tsline 1462), so a record left after the in-process stimd ends can only belong to another process. - Before fix: a command continues across a stimd restart, and a CI hold survives an exiting stimd #5612 the same ordering failed in the hold, with no replacement.
This is a test assumption, not a product defect. A CI hold that arrives after a persistent stimd decided to exit gets a replacement, as #5612 specifies. The product race in #5567 is a different case.
Fix idea
Make the order deterministic through a seam the file already spies on. Block the stimd's first tick (runHomePasses) until the hold is pinned, then assert that the held stimd is the in-process one. After that, wait on observed ticks instead of fixed 1200 ms sleeps. This keeps what the test protects: a held, quiescent persistent stimd outlives empty ticks and daemon.mode off, then exits once released.
Activity
janicduplessis commentedon Nov 13, 2026
Claimed: fix/5675-ci-hold-test-order
fix: hold the test's own stimd before it can idle out in the CI hold …
janicduplessis commentedon Nov 13, 2026
The same macOS-only assertion failed on #5658 at c9ab2e5, job 131685695801. The case
a CI hold keeps a quiescent persistent daemon alive through off modereached the finalexpected true to be falsefailure. The rest of that macOS test job passed or skipped. https://github.com/appandflow/stim/actions/runs/43364518261/job/131685695801