Skip to content

Flaky test: App WS bootstrap recovery fails under full-suite load (cross-file BroadcastChannel poisoning); fix reverted, needs proper landing #627

Description

@danshapiro

The bug

test/unit/client/components/App.ws-bootstrap.test.tsx > "recovers bootstrap-owned provider availability and sidebar filters after transient pre-ready 503s" is load-flaky in full client-suite runs: expected [ 'Manual Session' ], received [ 'Codex', 'Manual Session' ]. It passes 36/36 in isolation. Observed at 4c22976 and at a commit two earlier.

Root cause (empirically established; evidence in #625)

The vitest jsdom environment injects the worker-global Node BroadcastChannel into every test file. Layout broadcasts from OTHER test files (persistMiddlewarefreshell.persist.v2) can be delivered into a listener registered later by this file's mounted App (installCrossTabSync → layout hydration), hydrating a codex tab titled Codex into the test store — producing exactly the observed selector diff. Delivery is intermittent by worker/ordering chance (measured 2/6 in a two-file micro-experiment), hence the flake.

Current state

A candidate fix landed as #625 (2300258) and was reverted in #626. The full diff and evidence remain in #625:

  • App.ws-bootstrap.test.tsx: lifecycle-scoped inert BroadcastChannel stub; _resetSessionWindowThunkState() + _resetTerminalDirectoryThunkControllers() in beforeEach AND afterEach (a second, independently proven in-file residue channel); one added fence assertion. No assertions removed or loosened.
  • opencode-serve-manager.test.ts: raised onceIdle inner deadline/outer budget and eager attachment of the observation branch — remediation of a DIFFERENT pre-existing load flake, causally unrelated to this fix.

Verification state at the time of the revert: deterministic poison probe red-before/green-after; fixed file 36/36 in isolation and 35/35 in a saturated adversarial sweep including 5 seed-pinned replays of a recorded failing order (seed 1786259877991); 3/3 consecutive fully-green full client-suite runs at that HEAD; server suite showed 3 remote-proxy-family failures that also reproduce at the base commit.

Open items before relanding

  1. Committed regression protection: a live-channel poison guard was included and then removed because a live channel can itself contaminate other suites. If committed protection is wanted, design it as a non-live-channel test.
  2. Consider splitting the opencode-serve-manager.test.ts remediation into its own change — it is causally unrelated.
  3. Re-verify on current main before landing: fresh 3/3 consecutive full client-suite runs with the target passing, and confirm any server-suite failures reproduce at the base commit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions