test(app): settle code theme probes before teardown - #2484
Merged
ymichael merged 1 commit intoAug 26, 2026
Merged
Conversation
ymichael
deleted the
bb/ci-flake-fix-plugin-code-theme-async-teardown-thr_bu3nxrqd67
branch
August 26, 2026 18:59
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
plugin-code-theme.test.tsxobserved the real asynchronous Pierre theme resolutions, but it left three React render roots mounted until Testing Library's automaticafterEachcleanup. 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 missingwindow. 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 samewindow is not definedReact 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
7dc6756e20ba749ad9d4d6d939b1dd7de363250b(HEAD,origin/main, and merge-base all matched; worktree was clean).ReferenceError: window is not definedfrom React DOM/Scheduler. Minimized to one test with the same error.pnpm exec vitest run apps/app/src/lib/plugin-code-theme.test.tsx— 3/3 passed.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.