Repository navigation
Conversation
…Module
createModuleRecord index-aligned the AST import statements with JSC's
requestedModules(), but that list is deduplicated by specifier (first
occurrence wins). Any repeated specifier made the statements outnumber
the requests, shifting every later attributes lookup: debug builds hit
the ASSERT 'More attributes nodes than requests', and release builds
handed link() the wrong attributes for every import after the duplicate.
Map each unique specifier to its import attributes node (first occurrence
wins, mirroring ModuleAnalyzer's dedup) instead of aligning by position.
Build the attributes object from the literal with {} source, falling back
to the parsed fetch parameters only for export-from requests, which also
stops the internal hostDefinedImportType field from leaking into the
user-visible attributes.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
WalkthroughThis PR reworks how ChangesImport attribute mapping fix
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
Address review on duplicate import attribute handling: - requestedModules() dedups by (specifier, phase), not specifier alone, so a specifier-keyed node map could hand a request the wrong statement's attributes (import defer sharing a specifier with an attributed import, or an export-from winning the dedup race before a same-specifier import). Take the authoritative type from the request's own parsed fetch parameters, and use the import statement node only to recover non-type attribute keys the parser discards. - Remove the now-dead hostDefinedImportType builtin name; its only consumer was removed when the internal field stopped leaking into user attributes.
|
Updated 12:04 AM PT - Jul 7th, 2026
❌ @robobun, your commit a810bdd has some failures in 🧪 To try this PR locally: bunx bun-pr 33563That installs a local version of the PR into your bun-33563 --bun |
|
The diff is green locally and the CI failures are unrelated infra:
No failure touches |
|
Closing: this branch conflicts with main and #41654 carries the same fix, rebased on current main. |
What
vm.SourceTextModulehands the wrong import attributes to thelink()callback when the source repeats an import specifier, and aborts debug/canary builds outright.The idiomatic "import for bindings + import for side effects" pair is enough to crash a debug build:
Cause
NodeVMSourceTextModule::createModuleRecordwalked the AST's import statements in source order and index-aligned them with JSC'srequestedModules(). But that list is deduplicated by specifier (ModuleAnalyzer::appendRequestedModulekeeps only the first occurrence per specifier), so any repeated specifier makes the statements outnumber the requests and shifts every later index. On debug builds the twoASSERTs fire; on release the code readsattributesNodes.at(i)for the wrongi, so every JSON/CSS/host-defined type decision downstream of a duplicate is made on the wrong statement's attributes. Separately, a host-defined type (e.g.css) was copied into the user-visible attributes object as an internalhostDefinedImportTypefield.Fix
Map each unique specifier to its import attributes node (first occurrence wins, mirroring JSC's dedup) instead of aligning by position. Build the user-visible attributes object from the literal
with { ... }source, falling back to the parsed fetch parameters only for export-from requests; a host-defined type now surfaces as thetypevalue and the internalhostDefinedImportTypefield no longer leaks.Verification
New regression test in
test/js/node/vm/vm.test.tscovers the duplicate side-effect import, the dedup across a binding + side-effect import pair, and the css/json attribute mapping. It aborts the unfixed debug build (fail-before) and passes with the fix.