deno
cfceaa82 - fix: queue dynamic imports for modules with pending TLA (#31670)

Commit
201 days ago
fix: queue dynamic imports for modules with pending TLA (#31670) 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.
Author
Parents
Loading