Skip to content

esm: improve ERR_REQUIRE_ASYNC_MODULE#64260

Open
joyeecheung wants to merge 1 commit into
nodejs:mainfrom
joyeecheung:print-tla-2
Open

esm: improve ERR_REQUIRE_ASYNC_MODULE#64260
joyeecheung wants to merge 1 commit into
nodejs:mainfrom
joyeecheung:print-tla-2

Conversation

@joyeecheung

@joyeecheung joyeecheung commented Jul 2, 2026

Copy link
Copy Markdown
Member

This brings back several improvements that were reverted by mistake when landing #64154

  • Update the documentation about the removal of side effects of source collection
  • Add non-enumerable requireStack and topLevelAwaitLocations properties to ERR_REQUIRE_ASYNC_MODULE, the latter is only populated when --experimental-print-required-tla is enabled
  • Add "Required module: " to the error message to identify the required ESM entry point regardless of whether the flag is enabled
  • Fix TLA caret column from 0-based to 1-based
  • Store module source via a private symbol instead of a public property
  • Use hasAsyncGraph (post-instantiation) in throwIfAsyncGraph instead of walking the graph before instantiation
  • Merge the require stack checking into the common.expectRequiredTLAError helper.
  • Removed tests that are made redundant by the snapshot tests

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Jul 2, 2026
@joyeecheung

Copy link
Copy Markdown
Member Author

@aduh95 @anonrig as explained in #64154 (comment) these changes were reverted during the landing of #64154 by mistake. Since you approved #64154 before the accidental revert, can you review this again? Thanks!

@joyeecheung joyeecheung force-pushed the print-tla-2 branch 2 times, most recently from 1b62451 to 6ef0669 Compare July 2, 2026 14:44

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

This brings back several improvements that were reverted by mistake when
landing https://redirect.github.com/nodejs/node/pull/64154

- Update the documentation about how the removal of side effects of
  source collection
- Add non-enumerable `requireStack` and `topLevelAwaitLocations`
  properties to `ERR_REQUIRE_ASYNC_MODULE`, the latter is only
  populated when --experimental-print-required-tla is enabled
- Add "Required module: <url>" to the error message to identify the
  required ESM entry point regardless of whether the flag is enabled
- Fix TLA caret column from 0-based to 1-based
- Store module source via a private symbol instead of a public property
- Use `hasAsyncGraph` (post-instantiation) in `throwIfAsyncGraph`
  instead of walking the graph before instantiation
- Merge the require stack checking into the
  `common.expectRequiredTLAError` helper.
- Removed tests that are made redundant by the snapshot tests

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
@joyeecheung

Copy link
Copy Markdown
Member Author

@mcollina Thanks for the review! I forced pushed again to sync up the Windows line ending normalization in the tests. Can you take a look again?

@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 2, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 2, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.83721% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.03%. Comparing base (e6a8d06) to head (d64ed79).
⚠️ Report is 216 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/modules/esm/utils.js 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64260      +/-   ##
==========================================
+ Coverage   92.01%   92.03%   +0.01%     
==========================================
  Files         379      381       +2     
  Lines      166972   169161    +2189     
  Branches    25554    25919     +365     
==========================================
+ Hits       153639   155687    +2048     
- Misses      13041    13184     +143     
+ Partials      292      290       -2     
Files with missing lines Coverage Δ
lib/internal/errors.js 93.76% <100.00%> (+0.13%) ⬆️
lib/internal/modules/esm/loader.js 61.95% <100.00%> (+0.53%) ⬆️
lib/internal/modules/esm/module_job.js 88.15% <100.00%> (+2.75%) ⬆️
lib/internal/modules/esm/utils.js 84.14% <50.00%> (-0.86%) ⬇️

... and 93 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

errors Issues and PRs related to JavaScript errors originated in Node.js core. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants