Repository navigation
Conversation
The fast path in `load_dynamic_import` only knew a module had a pending
top-level await when the module was the root of a pending dynamic import.
A module still evaluating as a static dependency of one was not found
there, so `import()` handed out its namespace with the bindings
uninitialized ("Cannot access 'default' before initialization").
The fast path now asks V8 for the module's evaluation promise and, while
that is pending, takes the regular load path, which waits for it.
Fixes denoland#37261
This was referenced Dec 2, 2026
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 #37261
Related: #37259, #37260, #31670
A dynamic
import()of a module that is still in its top-level await resolved early, with the namespace's bindings uninitialized (Cannot access 'default' before initialization), when that module was being evaluated as a static dependency of another dynamic import.The fast path in
load_dynamic_importdetects a pending TLA by looking for the module inpending_dyn_mod_evaluations. That list only holds the root module of each dynamic import, so a dependency of it was never found there.The fast path now also asks V8 for the module's evaluation promise. While that promise is pending, the import takes the regular load path, which already waits for it.
This is independent of #37260. It also makes the reproduction from #37259 pass on its own, since the check does not rely on
pending_dyn_mod_evaluations.Testing
deno_coretesttest_dyn_import_pending_tla_of_static_dependency; it fails without the fix.cargo test -p deno_core --libpasses.default is function, andtests/specs/run/dynamic_import_pending_tla/main.mjsprints its expected output.AI disclosure
AI tools (Claude) were used to help write this change; it was reviewed by a human before submission.