Skip to content

stimd CI hold integration test assumes its in-process stimd is the one held #5675

Closed

Description

@janicduplessis

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

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.ts lines 1731 to 1753, EMPTY_TICKS_BEFORE_EXIT = 2). After the first empty tick it waits slowTickMs (2.5 s) only when memory and disk pressure are normal; otherwise it waits tickMs (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.ts holdCIStimd). 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, holdExistingStimd then replaces it (packages/stim-cli/src/daemon/client.ts lines 1567 to 1571 and 1603): ensureStimd spawns 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 running returns at once, because the in-process stimd ended long before. The replacement still runs and still owns stimd.json, so line 412 fails. shutdown removes the record only when it holds its own pid (main.ts line 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

  1. added
    type: bugBreaks documented or expected behavior
    priority: P1Next up: user-facing defect or unblocks other work
    area: clipackages/stim-cli, including its README and guide
    area: ciThe @stim-cli/ci package (packages/ci), not GitHub workflows
    on Nov 13, 2026
  2. janicduplessis commented on Nov 13, 2026

    @janicduplessis
    CollaboratorAuthor

    Claimed: fix/5675-ci-hold-test-order

  3. added a commit that references this issue on Nov 13, 2026
    2f4d9e2
  4. janicduplessis commented on Nov 13, 2026

    @janicduplessis
    CollaboratorAuthor

    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 mode reached the final expected true to be false failure. The rest of that macOS test job passed or skipped. https://github.com/appandflow/stim/actions/runs/43364518261/job/131685695801

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ciThe @stim-cli/ci package (packages/ci), not GitHub workflowsarea: clipackages/stim-cli, including its README and guidepriority: P1Next up: user-facing defect or unblocks other worktype: bugBreaks documented or expected behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions