Repository navigation
Fix seeded ordering, network, and timing test flakes - #4963
Merged
ymichael merged 2 commits intoOct 5, 2026
Merged
Conversation
ymichael
deleted the
bb/investigate-and-fix-recent-test-flakes-thr_98y6kafg7n
branch
October 5, 2026 23:51
ymichael
added a commit
that referenced
this pull request
Oct 6, 2026
…4976) ## Human comments ## What was wrong Recent CI failures came from independent lifecycle and readiness races, shared test state, and live registry resolution. A review of 900 recent CI runs classified 213 distinct failing test names; broad shuffled runs then exposed additional icon-generation and app teardown/order failures. A refresh of newer main runs found three more failures from the generated-bundle checker race fixed here. This follows #4963. Evidence includes [host/ACP failures](https://github.com/get-bb/bb/actions/runs/37389341709), [browser ownership](https://github.com/get-bb/bb/actions/runs/37389714139), [Claude permissions](https://github.com/get-bb/bb/actions/runs/37388331904), [Pi PID reuse](https://github.com/get-bb/bb/actions/runs/37285422900), [server move](https://github.com/get-bb/bb/actions/runs/37374976858), [environment cleanup](https://github.com/get-bb/bb/actions/runs/37095834703), and [registry resolution](https://github.com/get-bb/bb/actions/runs/37386279602). ## What changed - Host plugin shutdown now shares one directory-cleanup promise instead of deleting the same directory concurrently. - ACP and browser child fixtures publish usable readiness after signal handlers are installed. Pi fixtures use actual child handles rather than probing retired, potentially reused PIDs. - Claude permission tests wait for the expected request; server retirement and environment cleanup tests await lifecycle completion; Tasks tests wait until form submission is enabled. - The server-move fixture retains its listening socket until the child accepts ownership, removing the free-port selection race. - The integration harness stops plugins and closes WebSockets during shutdown, matching production. - External scaffolds install the packed SDK offline using locked local dependencies. - PWA generation skips unchanged assets and publishes changed files atomically, preventing concurrent checks from reading truncated icons. - The provider-literal checker excludes generated Wrangler and SDK runtime-test bundles while continuing to scan adjacent source files. A [native Windows reproduction](https://github.com/get-bb/bb/actions/runs/37395770823) identified `apps/demo-server/.wrangler/tmp/dev-*/worker.js` as the extra provider-reference source. - The filesystem-watcher test awaits actual change events under its existing test watchdog and propagates errors received after readiness. - The cold-loading toast test runs in its own isolated environment. Palette tests complete Radix's scheduled focus cleanup before disposing jsdom. - Replay initialization is limited to four simultaneous workers; initialized replays retain their existing concurrency. Queue slots release on initialization, timeout, exit, signal, and spawn failure. No wire, public API, or user-facing configuration changes. ## How you verified Controlled before/after failures cover duplicate directory cleanup, readiness publication, stale PID probes, delayed permission delivery, retirement/cleanup scheduling, occupied ports, disabled form submission, open WebSocket shutdown, concurrent icon checking, shuffled toast startup, unfinished focus cleanup, delayed native filesystem events, and generated bundles appearing in the source scan. The replay regression launches eight real workers, checks the initialization bound, then verifies all eight can replay concurrently; failure cases verify queued work completes and children exit. - First repository shuffle (seed 61973) passed 14,512 tests outside the app; its icon precheck and subsequent app failures produced the fixes above. - Focused verification passes: six replay-helper regressions, all 59 recorded parity cases, 616 host source tests, all 74 integration tests, all 41 Tasks manage tests, and 17 affected app tests. Changed-package lint/typechecks pass. - [Native Windows shutdown verification](https://github.com/get-bb/bb/actions/runs/37394517960) passes the formerly failing live-WebSocket regression and three environment-isolation repetitions. - [Windows startup measurements](https://github.com/get-bb/bb/actions/runs/37393953100): limiting startup to four reduced maximum cold initialization from 15.8s to 2.8s and suite duration from 44.1s to 27.3s, while keeping peak live replays at 16. The original 60-second initialization timeout did not reproduce; this is a measured contention mitigation, not a proven diagnosis of that exact failure. - Second repository shuffle (seed 82317): 19,886 tests passed, including all 5,370 app tests; one watcher readiness failure led to the final event-wait fix. The complete watcher suite then passed (56 tests), and the scripts suite passed all 201 tests with the artifact exclusions. - CI at 2712483 passed 30 checks; its sole failure was the generated-bundle checker race fixed in f4e976b. - Final repository-wide shuffle (seed 90071) passes: **19,889 tests across 92 package suites; all 106 Turbo tasks passed**, with no unhandled errors. - [Native Windows scanner after-proof](https://github.com/get-bb/bb/actions/runs/37396098532) passes 15 demo tests and the source scan with exactly 14 references across six allowlisted source files. - [Linux/Windows CI at f4e976b](https://github.com/get-bb/bb/actions/runs/37396210581) is green: **all 31 non-skipped checks passed** (three intentionally skipped). Diff scope: four production/tooling files (+392/-317, mostly replay-helper try/finally indentation) and 23 tests/support files (+745/-230). > AGENT GENERATED
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.
Human comments
What was wrong
Recent CI failures had several independent causes: seeded shuffling consumed nondeterministic file-discovery order; Miniflare's rate limiter reset at minute boundaries during a 61-request test; worker startup and D1 migrations ran inside tests with a 5-second deadline; two marketplace image tests fetched GitHub avatars; and exhaustive provider-fixture validation exceeded its default 5-second deadline. Investigation covered 159 main-branch CI runs from October 2–5 and same-commit retries. Follow-up investigation also found that successful replays retained a shutdown timeout which later mutated their returned result into a false failure. Examples: seeded ordering failure, rate-limit failure, and image/provider timeout failures.
What changed
No product or wire changes. A separate Windows provider replay initialization timeout remains unresolved and is not claimed as fixed here.
How you verified
@bb/scripts,@bb/ai-gateway,@bb/web, and@bb/provider-parity: 466 tests total (198 scripts, 35 gateway, 174 web, 59 provider parity).git diff --check, and independent final diff review passed. Ten diagnostic runs on native Windows passed all 59 parity tests each. The instrumented comparison captured 280 successful initializations: cold baseline median 24.9s / max 29.1s, warm baseline median 2.1s / max 4.4s. Limiting concurrent replays reduced startup time but increased suite duration from 29.5–51.1s to 116–119s; that experiment was not retained. The original 60-second initialization timeout remains unreproduced and unresolved. Temporary diagnostic changes were kept off this PR.