Skip to content

fix: return the mock to concurrent imports - #11623

Merged
sheremet-va merged 3 commits into
mainfrom
fix/concurrent-mock-imports
Oct 16, 2026
Merged

sheremet-va merged 3 commits into
mainfrom
fix/concurrent-mock-imports

Conversation

@sheremet-va

@sheremet-va sheremet-va commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Fixes #7040

  • Imports that start while a mock factory runs wait for it and get the same mock. Only imports made inside the factory get the original module; this is now tracked with AsyncLocalStorage instead of a marker on the importer's shared callstack.
  • A factory that imports a module waiting for the mock gets its partial exports, like a regular import cycle, instead of hanging.
  • Concurrent imports wait for mocks that resolveMocks is still registering.
  • Concurrent imports of an automocked or spied module wait until the original module is evaluated and mocked. The second importer used to get the automock object before it was filled.

@sheremet-va
sheremet-va merged commit 1453ba6 into main Oct 16, 2026
@sheremet-va
sheremet-va deleted the fix/concurrent-mock-imports branch October 16, 2026 16:16
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot dynamic import multiple times a mocked module

1 participant