Make the test suite runnable under bun test --parallel - #915
Open
Gustav-Simonsson wants to merge 5 commits into
Open
Make the test suite runnable under bun test --parallel#915Gustav-Simonsson wants to merge 5 commits into
bun test --parallel#915Gustav-Simonsson wants to merge 5 commits into
Conversation
The parallel test matrix exposed three tests that raced wall-clock time. Approval-log tests slept a fixed 10 ms before reading a JSONL log that is appended fire-and-forget, so a slightly loaded event loop dropped the last record; the transcript anchor test slept a fixed 250 ms for the async tree-sitter highlighter to paint, which the parallel load exceeds; and the stall-recovery tests measured a 30 ms stall window against Date.now, so a load gap between awaited decides tripped a spurious stall nudge. Await the actual condition instead of sleeping: the approval log now exposes a flush that resolves its append tail, the transcript test polls for the newest painted row, and the stall tests inject a frozen clock, which the constructor already accepted.
bun test --parallel on Bun 1.4.x intermittently livelocks: a worker spins at 100% CPU holding a zombie git child while the main process idles with no output, and bun test has no run-level timeout, so a stalled run hangs forever (upstream oven-sh/bun bug, still open on 1.4.2, reproduced locally at ~50% of runs with 4 workers). A healthy run never exceeds 0.64s of output silence, so the wrapper runs the seeded suite in its own process group, kills the whole group after 90s of silence, and retries up to 3 times. A child that exits on its own, pass or fail, is never retried, so real failures still fail the gate. CI keeps sharded sequential runs and is unaffected.
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.
Summary
bun test --parallelon Bun 1.4.x can livelock (upstream oven-sh/bun#36235): aworker spins at 100% CPU with no output, and since
bun testhas no run-leveltimeout, the hang is permanent. This PR adds a safe local parallel mode and removes
unnecessary fixed sleeps from the tests.
bun run test:parallel [N](default 4 workers) runs the same seeded suite asbun run testwith--parallel=N, under a watchdog (scripts/test-parallel.ts).If the suite produces no output for 90 s, the watchdog kills its process group and
restarts it (3 attempts total). A run that exits on its own is never retried, so
real test failures still fail the gate.
time, which makes them stable under parallel load and removes dead time.
agents-panel linger) can now be shortened via optional config values that
production code does not set.
Full-suite wall time: ~21 s with
test:parallelvs ~75 s sequential at thebase commit (≈3.5×). Sequential runs are also ~1.3× faster from the removed waits.
CI is unchanged (sharded sequential
test:paths).Unchanged production behavior
are the previous hard-coded values, and no production call site sets them.
added, removed, or modified. The only new tests (+6) cover the watchdog wrapper.
Verification
bun run typecheckandbun run lintpass at HEAD.base 6765 pass / 1 skip / 4 fail, HEAD 6771 pass / 1 skip / 4 fail. The 4 failures
also occur on the unmodified tree in this environment (permission/git sandbox
issues) and are unrelated to this PR.
--parallellivelock reproduces on the base commit, and the watchdog rescued alive occurrence during verification (killed the stalled run after 90 s; the retry
completed in 21.2 s).
src/agent/exa-web-fetch-alias.test.ts(untouched by this PR) hit Bun's 5 s per-test timeout in one run. They pass
sequentially and in isolated parallel runs.
Test plan
bun run test:parallel— local full-suite run with the stall watchdog.bun run test— unchanged sequential mode.test:paths).