Conversation
Adds vi.resetModules() to beforeEach in all 7 announcement test files that use dynamic await import() calls, preventing stale module cache state from bleeding across concurrent vitest workers. Also adds testTimeout:10000 to vitest.config.ts so a stalled test fails with its name rather than silently exhausting the 60s precommit budget. Closes #3092 https://claude.ai/code/session_01RRJENfLEsQ47mMs4NZKUaa
The original comment said "cached module from another thread bleeds" which is wrong: vitest 4.x pool:'threads' isolates each file in its own worker. The actual bug is within-file — repeated await import() returns the same cached instance, and clearAllMocks() doesn't clear the module registry. Fix comment in all 7 patched files. https://claude.ai/code/session_01RRJENfLEsQ47mMs4NZKUaa
This was referenced Apr 25, 2026
Closed
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.
Closes #3092
Summary
Under
--pool=threads, vitest workers share the module registry. The 7tests/announcement/files that use dynamicawait import()inside test bodies were susceptible to stale module state bleeding across concurrent workers — manifesting asTypeError: Cannot read properties of undefinedand 5 s timeouts when the machine is under Conductor multi-workspace load.Changes:
vi.resetModules()as the first call inbeforeEachin all 7 affected test files (announcement-backlog,announcement-backlog-route,announcement-admin-route,announcement-handlers,announcement-backfill,announcement-channel-resolver,announcement-reminder). This clears the module registry before each test so the subsequentawait import()always resolves a fresh module with thevi.mockfactory applied cleanly.mockLoadAnnouncementBacklog.mockReset()toannouncement-backlog-route.test.tsbeforeEach—clearAllMocks()alone does not drain unconsumedmockResolvedValueOncequeues.testTimeout: 10000tovitest.config.tsso a single stalled test fails with its name rather than silently consuming the entire 60 s precommit budget.Non-breaking justification: test-only changes; no production code modified;
--pool=threadsconfig preserved (required to avoid non-TTY stdin hang in pre-commit hook — see comment invitest.config.ts).Pre-PR review:
Session: https://claude.ai/code/session_01RRJENfLEsQ47mMs4NZKUaa
Generated by Claude Code