test: fix flaky CI in flock stress + run-process subprocesses - #49
Open
filipeforattini wants to merge 1 commit into
Open
test: fix flaky CI in flock stress + run-process subprocesses#49filipeforattini wants to merge 1 commit into
filipeforattini wants to merge 1 commit into
Conversation
Two unrelated flakes were tripping CI on the 0.8.0 release: 1. packages/core/test/util/effect-flock.test.ts "enforces mutual exclusion under process contention" failed on Windows with one of 16 workers exiting 1. The `active` marker file lives outside the lock directory, so its `wx` create races between a holder's `fs.rm(active)` and the next holder's `fs.writeFile(active)`; on Windows the race window is wide enough that one worker keeps losing the race. Drop the marker from this specific test — the serialized work and `done.log` line count below already prove mutual exclusion. (The `active` mechanism stays in place for the single-worker "recovers after a crashed lock owner" test where there is no race.) 2. packages/opencode/test/lib/cli-process.ts spawned `bun run --conditions=browser src/index.ts` per subprocess, costing ~20s of transpile + plugin init each on CI. With 11 cliIt.concurrent tests starting at once on a shared CPU runner, individual startup times stretched past the 30s `timeoutMs` baked into the harness. Use the prebuilt redcode binary (`dist/redcode-linux-x64/bin/redcode`) when present; fall back to bun when no built binary exists yet. Local run of run-process.test.ts dropped from ~60s to ~40s. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two unrelated flakes tripping CI on the 0.8.0 release:
1. flock stress flake (Windows only)
packages/core/test/util/effect-flock.test.ts:330"enforces mutual exclusion under process contention" failed on Windows with one of 16 workers exiting 1.Root cause: the
activemarker file lives outside the lock directory, so itswxcreate races between a holder'sfs.rm(active)and the next holder'sfs.writeFile(active). On Windows the race window is wide enough that one worker keeps losing the race even though the flock itself is correct.Fix: drop the
activemarker from this specific test. The serialized work anddone.logline count below already prove mutual exclusion. Theactivemechanism stays in place for the single-worker "recovers after a crashed lock owner" test where there's no race.2. run-process flake (Linux CI, all 0.8.0 candidate tests)
packages/opencode/test/cli/run/run-process.test.tsfailed three times on Linux at exactly 30s —appProc.runwas timing out.Root cause: the harness spawned
bun run --conditions=browser src/index.tsper subprocess. That's ~20s of transpile + plugin init per spawn. With 11cliIt.concurrenttests starting at once on a shared-CPU CI runner, individual startup times stretched past the 30stimeoutMsbaked into the harness.Fix: prefer the prebuilt
redcodebinary (dist/redcode-linux-x64/bin/redcode) when present; fall back to bun otherwise. Local run ofrun-process.test.tsdropped from ~60s to ~40s. CI should be well under the 30stimeoutMsper test.Verification
bun test test/util/effect-flock.test.ts— 11 pass, 0 failbun test test/cli/run/run-process.test.ts— 13 pass, 0 fail, 3 consecutive runsNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.