Repository navigation
ESM Linkage Error Decoration can throw errors subsuming the original #37812
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.policyHistorical issues and PRs related to the removed policy-manifest feature.Historical issues and PRs related to the removed policy-manifest feature.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Description
- Version: all LTS
- Platform: all
- Subsystem: module, esm, policy
What steps will reproduce the bug?
Produce an error in the lines:
node/lib/internal/modules/esm/module_job.js
Lines 116 to 118 in 5f2bb88
| const childFileURL = | |
| await this.loader.resolve(childSpecifier, parentFileUrl); | |
| const format = await this.loader.getFormat(childFileURL); |
How often does it reproduce? Is there a required condition?
Every time.
It is only possible to reproduce with a Loader or Policy.
What is the expected behavior?
See the original error with linkage, preferably decorated properly.
What do you see instead?
The error that was thrown while attempting to decorate the original error.
Additional information
This was discovered by @giltayar on https://github.com/giltayar/import-map-to-policy/tree/127d3b068dc1e984708beed3dc5eaf4b116ff68e , which when running npm run start:node produced a very confusing:
$ NODE_DEBUG=policy,esm,module node --experimental-policy ./policy.json -- src/node-main.js
POLICY 58628: Manifest contains integrity for resource ./src/node-main.js
POLICY 58628: Manifest contains integrity for resource ./src/write-answer/write-answer.js
POLICY 58628: Manifest contains integrity for scope file:
POLICY 58628: Checking integrity of file:///Users/bfarias/Documents/oss/import-map-to-policy/package.json
(node:58628) ExperimentalWarning: Policies are experimental.
(Use `node --trace-warnings ...` to show where the warning was created)
ESM 58628: Storing file:///Users/bfarias/Documents/oss/import-map-to-policy/src/node-main.js in ModuleMap
POLICY 58628: Checking integrity of file:///Users/bfarias/Documents/oss/import-map-to-policy/src/node-main.js
ESM 58628: Translating StandardModule file:///Users/bfarias/Documents/oss/import-map-to-policy/src/node-main.js
ESM 58628: Storing file:///Users/bfarias/Documents/oss/import-map-to-policy/src/write-answer/write-answer.js in ModuleMap
POLICY 58628: Checking integrity of file:///Users/bfarias/Documents/oss/import-map-to-policy/src/write-answer/write-answer.js
ESM 58628: Translating StandardModule file:///Users/bfarias/Documents/oss/import-map-to-policy/src/write-answer/write-answer.js
ESM 58628: Storing file:///Users/bfarias/Documents/oss/import-map-to-policy/src/answer/answer.js in ModuleMap
POLICY 58628: Checking integrity of file:///Users/bfarias/Documents/oss/import-map-to-policy/src/answer/answer.js
ESM 58628: Translating StandardModule file:///Users/bfarias/Documents/oss/import-map-to-policy/src/answer/answer.js
node:internal/process/esm_loader:74
Error [ERR_MANIFEST_DEPENDENCY_MISSING]: Manifest resource file:///Users/bfarias/Documents/oss/import-map-to-policy/src/node-main.js:1 does not list write-answer as a dependency specifier for conditions: node, import
at new NodeError (node:internal/errors:329:5)
at Loader.defaultResolve [as _resolve] (node:internal/modules/esm/resolve:821:18)
at Loader.resolve (node:internal/modules/esm/loader:86:40)
at ModuleJob._instantiate (node:internal/modules/esm/module_job:117:31)
at async ModuleJob.run (node:internal/modules/esm/module_job:151:5)
at async Loader.import (node:internal/modules/esm/loader:166:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5) {
code: 'ERR_MANIFEST_DEPENDENCY_MISSING'
}You can note the :1 that comes from the wrong URL being used when decorating, this caused an error in resolve to subsume the original:
file:///Users/bfarias/Documents/oss/import-map-to-policy/src/write-answer/write-answer.js:1
import {theAnswer} from 'answer'
^^^^^^^^^
SyntaxError: The requested module 'answer' does not provide an export named 'theAnswer'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:105:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:151:5)
at async Loader.import (node:internal/modules/esm/loader:166:24)
at async Object.loadESM (node:internal/process/esm_loader:68:5)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.policyHistorical issues and PRs related to the removed policy-manifest feature.Historical issues and PRs related to the removed policy-manifest feature.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Activity
github-actions commentedon Jun 27, 2026
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
github-actions commentedon Jul 28, 2026
This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.