Repository navigation
Conversation
`evaluate_dyn_imports` took the whole list of pending dynamic module
evaluations and only put the still pending ones back after resolving the
settled ones. Resolving runs a microtask checkpoint, so code resumed by it
could `import()` a module still in its top-level await while the list was
empty. `load_dynamic_import` then saw no pending evaluation and handed out
the namespace with its bindings uninitialized ("Cannot access 'default'
before initialization").
The still pending evaluations now go back before any import is resolved.
Follow-up to denoland#31670, which queued such imports as TLA waiters.
Fixes denoland#37259
This was referenced Dec 2, 2026
Author
|
Note for reviewers: there are two ways to fix #37259, and I opened both so you can choose.
The two are independent and can both land; they only conflict textually at the end of |
This branch has not been deployed
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.
Fixes #37259
Follow-up to #31670
A dynamic
import()of a module that is still in its top-level await could resolve early, with the namespace's bindings uninitialized (Cannot access 'default' before initialization), when another dynamic import settled in between.evaluate_dyn_importstook the whole list of pending dynamic module evaluations and only put the still pending ones back after resolving the settled ones. Resolving runs a microtask checkpoint, so code resumed by it could callimport()for a module with a pending TLA while the list was empty.load_dynamic_importthen found no pending evaluation and resolved right away instead of queueing a TLA waiter.The still pending evaluations now go back into the list before any import is resolved.
Testing
deno_coretesttest_dyn_import_pending_tla_while_other_import_settles; it fails without the fix.cargo test -p deno_core --libpasses.{"second":"default is function","first":"default is function"}on a debug build with the fix.AI disclosure
AI tools (Claude) were used to help write this change; it was reviewed by a human before submission.