Skip to content

Conversation

@fraidev
Copy link
Contributor

@fraidev fraidev commented Dec 19, 2025

still a draft

Needs:

Solution for:
#29123
denoland/deno_core#1149

When a module with Top-Level Await (TLA) is dynamically imported multiple times before the TLA resolves, subsequent imports would fail with "Cannot access 'default' before initialization".

This happened because V8 sets module status to Evaluated immediately after calling module.evaluate(), even when TLA is pending. Deno would see Evaluated status and try to resolve immediately, exposing uninitialized bindings (TDZ violation).

The fix queues subsequent import resolvers in pending_tla_waiters when a module has pending TLA, and resolves them all when the TLA promise completes.

@fraidev fraidev changed the title Fix/dynamic import pending tla fix: queue dynamic imports for modules with pending TLA Dec 19, 2025
@fraidev fraidev marked this pull request as ready for review December 19, 2025 04:33
@fraidev fraidev changed the title fix: queue dynamic imports for modules with pending TLA fix: queue dynamic imports for modules with pending TLA [Draft] Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant