Skip to content

Keep the first run marker tests off the host's free disk space - #160

Merged
MatiasFernandez merged 2 commits into
mainfrom
mfernandez/fix-space-flakiness
Oct 20, 2026
Merged

MatiasFernandez merged 2 commits into
mainfrom
mfernandez/fix-space-flakiness

Conversation

@MatiasFernandez

@MatiasFernandez MatiasFernandez commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Three unit tests in activation.test.ts fail on any machine with less than about 12 GB free: both cases of "the first run marker" (cancelled/failed) and "never asks about shared memory on first run for an external database". That is what failed CI on #148, hours after main passed on the same code.

The marker tests run the real runSetup, which reaches prepareFiles and the real assertRoomForSetup. On a low-disk host that throws DiskSpaceError, runSetup returns failed, and the cancelled case fails its assertion before it calls releaseOs. That leaves the first-run setup lock held (heldHere in lock.ts is module-level), so the next two tests wait on it and time out with expected +0 to be 1.

Two changes:

  • Stub the host checks prepareFiles makes (assertRoomForSetup and assertDatabaseIsLocal) in the existing ../database mock, next to assertDatabaseMatchesEngine and createDatabase. setup.test.ts already stubs both the same way. The NFS check reads the host's file system the same way the free-space check does: with TMPDIR on NFS, the marker tests failed for that reason too (reproduced in review).
  • Release the OS step in a finally, so any future failure of that runSetup assertion stays in the test that has it. Without this the stub removes one trigger, but the next unrelated failure there would again show up as timeouts in tests that never touch it.

The stubs leave assertRoomForSetup with no unit coverage, which was already true on main: these tests ran the real check only by accident and asserted nothing about it. Tests for it, a sturdier release of the OS step (one that also holds on a timeout), and one shared inert ../database mock are tracked in #161.

Verified on a Mac with 7.1 GB free. Before the change, npx vitest run src/__tests__/activation.test.ts gave 3 failed and 32 passed, and the full npm test gave 3 failed and 1058 passed. After it, the file passes 35/35 and npm test passes 1061/1061. To check the finally, I temporarily removed the free-space stub: only the two marker cases failed, each with the real expected 'failed' to be 'completed', and the external-database test passed. Lint, format check and both typechecks are clean.

🤖 Generated with Claude Code

@MatiasFernandez
MatiasFernandez marked this pull request as ready for review October 20, 2026 17:35
@ericwinger
ericwinger self-requested a review October 20, 2026 18:16

@ericwinger ericwinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with comments.

Comment thread src/__tests__/activation.test.ts
Comment thread src/__tests__/activation.test.ts
Comment thread src/__tests__/activation.test.ts Outdated
Comment thread src/__tests__/activation.test.ts
Comment thread src/__tests__/activation.test.ts
MatiasFernandez and others added 2 commits October 20, 2026 15:45
Stub the free-space and NFS checks that the real runSetup reaches through
prepareFiles, as setup.test.ts already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The marker tests resolve the pending OS step only after their runSetup
assertion. When that assertion failed, the first-run work kept the setup
lock (heldHere is module-level), and the next tests failed waiting on it
with errors that named neither the cause nor the test that caused it.
Releasing it in a finally keeps a failure in the test that has it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MatiasFernandez
MatiasFernandez force-pushed the mfernandez/fix-space-flakiness branch from 1e01885 to 3e7e1d9 Compare October 20, 2026 18:45
@MatiasFernandez
MatiasFernandez added this pull request to the merge queue Oct 20, 2026
Merged via the queue into main with commit 9d84e10 Oct 20, 2026
8 of 10 checks passed
@MatiasFernandez
MatiasFernandez deleted the mfernandez/fix-space-flakiness branch October 20, 2026 19:21
@jgfoster jgfoster mentioned this pull request Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants