CI flake: vitest browser-mode resolveManualMock RPC race fails CI after green tests #1080
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks#1080
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
Every test in
apps/webpasses, then the runner exits with code 1 on an unhandled rejection during teardown:Failure path
RouteHandlerkeeps intercepting requests forvi.mock'd modules — its lifecycle is the page, not the runner.resolveManualMockover the closed RPC.Affected versions
vitest4.1.5@vitest/browser-playwright4.1.5playwright-core1.59.1Affected PRs / runs (already)
47b47f0a(fix(web): wait for drawer unmount in app-shell test),ccc3be9c(fix(ci): await unmount in nav-sections re-render test),60760cca(fix(web): serialise vitest browser test files to dodge dep-optimizer race— addsfileParallelism: false). Each fixed a near-cause; none caught this race.Workaround currently in place
apps/web/vitest.config.tsexcludes the loudest leakers:src/components/app-shell.test.tsxsrc/components/nav-sections.test.tsxsrc/components/sidebar-nav.test.tsxThis restores green CI but cuts coverage on those three components. Re-enable as part of the fix.
Fix attempts that did NOT work
optimizeDeps.includeforreact-dom/client+@base-ui-components/react/radio[-group]— kills the mid-suite "Vite unexpectedly reloaded a test" reload warning, but the RPC race fires regardlessvi.mock("@tanstack/react-router", async () => ({ ...await vi.importActual(...), ...routerStubs }))with a syncvi.mock("@tanstack/react-router", () => routerStubs)— only addresses one of ~10 async factories in the suiteglobalSetupprocess.on("unhandledRejection", ...)swallow restricted to the exact RPC-closed message — handler attached but the rejection is not caught (the rejection appears to fire in a context where this handler is not active — possibly a child process or a different async hook chain)Fix directions worth trying
@vitest/browser-playwrightversions until a release without the race. 4.1.5 is the current pin; check 4.1.4 / 4.0.x or whatever the upstream issue tracker recommends.vi.mock(..., async () => …)factory in the suite to a sync factory — eliminates the source of lateresolveManualMockcalls. ~10 files:app-shell.test.tsx,nav-sections.test.tsx,sidebar-nav.test.tsx,avatar-menu.test.tsx,watchdog-panel.test.tsx,settings.repos.test.tsx,settings.service.test.tsx,settings.voice-input.test.tsx,settings.agents.admin.test.tsx,settings.agent-config.test.tsx,agents.live.test.tsx,agents.facets.test.tsx,agents.roster.test.tsx,agents.sessions.test.tsx,settings.language.test.tsx,board/board.test.tsx,features/agent-config/history-tab.test.tsx(grepvi.mock.*async\\|importActualto confirm).Acceptance criteria
app-shell.test.tsx,nav-sections.test.tsx,sidebar-nav.test.tsx) are re-enabled with no exclude entries beyonde2e/**+settings-manifest.test.tsvi.mock(..., async () => { … vi.importActual(...) … })factories remain (or the fix proves they are safe)References
🦵 @charles kicked the queue — re-running implement on @code-lead.