Skip to content

test(app): settle code theme probes before teardown - #2484

Merged
ymichael merged 1 commit into
mainfrom
bb/ci-flake-fix-plugin-code-theme-async-teardown-thr_bu3nxrqd67
Aug 26, 2026
Merged

test(app): settle code theme probes before teardown#2484
ymichael merged 1 commit into
mainfrom
bb/ci-flake-fix-plugin-code-theme-async-teardown-thr_bu3nxrqd67

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

plugin-code-theme.test.tsx observed the real asynchronous Pierre theme resolutions, but it left three React render roots mounted until Testing Library's automatic afterEach cleanup. React 19 can queue follow-up Scheduler work while those roots are cleaned up; because that cleanup happened at file teardown, shard contention could let Vitest dispose jsdom first and the queued task then read the missing window. The failing CI run had exactly three post-test exceptions, matching the three roots left for automatic cleanup; the first consumer in the third test was explicitly unmounted and did not produce a fourth exception. A deterministic teardown harness reproduced the same window is not defined React DOM/Scheduler stack while every assertion passed, then stopped reproducing when the root was explicitly unmounted. This isolates the leak to test lifecycle ownership rather than the production hook or its resolver cancellation guard. See the failing app-1 job and the subsequent passing app-1 job.

What changed

Each test now explicitly unmounts every probe after its asynchronous assertions settle. The cached-theme test also retains the second probe long enough to unmount it. There are no production, wire-protocol, CLI, guide, or documentation changes.

How you verified

  • Verified merge-base before inspection and implementation: 7dc6756e20ba749ad9d4d6d939b1dd7de363250b (HEAD, origin/main, and merge-base all matched; worktree was clean).
  • Temporary deterministic teardown harness before: 3/3 test assertions passed, then Vitest reported the exact unhandled ReferenceError: window is not defined from React DOM/Scheduler. Minimized to one test with the same error.
  • Same deterministic harness after: 3/3 passed and the former post-test Scheduler callback was no longer queued.
  • pnpm exec vitest run apps/app/src/lib/plugin-code-theme.test.tsx — 3/3 passed.
  • 100 parallel focused invocations — all passed with no unhandled errors.
  • pnpm exec turbo run test --filter=@bb/app --cache-dir=.turbo/cache --output-logs=new-only --force -- --shard=1/3 — 146 files passed; 1125 tests passed, 3 skipped.
  • pnpm exec turbo run test --filter=@bb/app --cache-dir=.turbo/cache --output-logs=new-only --force — 438 files passed; 3418 tests passed, 3 skipped.
  • pnpm exec turbo run typecheck --filter=@bb/app — passed.
  • pnpm exec turbo run build --filter=@bb/app — passed.

AGENT GENERATED: by GPT-5.6-Sol

@ymichael
ymichael merged commit 0ee5432 into main Aug 26, 2026
15 checks passed
@ymichael
ymichael deleted the bb/ci-flake-fix-plugin-code-theme-async-teardown-thr_bu3nxrqd67 branch August 26, 2026 18:59
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.

1 participant