Skip to content

fix(core): await cached async modules before resolving dynamic imports - #37098

Open
BlackRam-oss wants to merge 1 commit into
denoland:mainfrom
BlackRam-oss:codex/fix-cached-static-tla
Open

BlackRam-oss wants to merge 1 commit into
denoland:mainfrom
BlackRam-oss:codex/fix-cached-static-tla

Conversation

@BlackRam-oss

Copy link
Copy Markdown

Fixes #37097.

A cached module can have V8 status Evaluated while its async evaluation promise is still pending. The shortcut only checks dynamic-evaluation records, so a statically evaluated root or an async descendant can expose its namespace too early (including uninitialized exports).

Skip this shortcut for async graphs and let the existing evaluation-promise path settle them. Synchronous graphs retain the fast path. No new API, dependency, module graph, or wrapper is introduced.

The regression starts a static graph with host-resolved TLA, imports either its root or its async dependency, checks that the import stays pending, then resolves it and checks the value and cached namespace identity/single evaluation.

Validation performed:

  • The regression body was executed as a standalone public-API embedding test against the patched published deno_core0.413.0 package.
  • An independent embedding matrix covers root/descendant fulfillment and rejection, error identity, cached namespace identity and single fetch/evaluation; full embedding suites passed117 normal/116 JITless (existing2/3 ignored).
  • The same matrix fails on the unmodified crate because settlement occurs before the resolver.
  • New Rust test formatted with the repository's max_width80/tab_spaces2/edition2024 settings.

Full monorepo ./x fmt, ./x lint, and core tests have not been run locally; keeping this draft pending upstream CI/review. No performance benchmark is claimed: already-settled async graphs also take the general path with this conservative fix.

AI assistance: prepared with OpenAI Codex. The checks listed above were actually executed; unrun monorepo checks are explicitly distinguished.

NetOpWibby pushed a commit to theende/ende that referenced this pull request Nov 7, 2026
V8 reports `Evaluated` for a module whose async evaluation is still
pending. The cached-module fast path in `load_dynamic_import` only
checked `pending_dyn_mod_evaluations`, which doesn't cover a statically
started evaluation or an async dependency of it, so `import()` of such a
module resolved with exports still in TDZ. Async graphs now skip the
fast path and wait on the module's evaluation promise; sync graphs keep
it.

(cherry picked from commit 49a03aaf1ae59c864539c88f510ef0582073826e)

Upstream: denoland/deno#37098
@CLAassistant

CLAassistant commented Nov 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@BlackRam-oss
BlackRam-oss marked this pull request as ready for review November 8, 2026 10:47

This branch has not been deployed

No deployments
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.

deno_core: cached dynamic import can resolve before static top-level await completes

2 participants