GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — module: fix require(esm) on the module.register() hooks thread by mcollina · Pull Request #66770 · nodejs/node

Conversation

@mcollina

@mcollina mcollina commented Oct 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Since #62530, require() of an ES module that has imports, done while a module.register() hooks module is loading on the hooks thread, fails with ERR_INTERNAL_ASSERTION in ModuleJobSync.syncLink().

#62530 made getOrCreateModuleJob() resolve asynchronously for every request on the hooks thread, and switched kImportInRequiredESM jobs there to ModuleJob. This restores the previous behavior for those request types: kImportInRequiredESM and kRequireInImportedCJS are always resolved synchronously, and kImportInRequiredESM always uses ModuleJobSync. The main-thread behavior from #62530 is unchanged.

Fixes: #66767


AI generated, reviewed by me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mcollina
module: fix require(esm) on the module.register() hooks thread
eb35469
On the async loader hooks thread, resolve kImportInRequiredESM and
kRequireInImportedCJS requests synchronously again, and always use
ModuleJobSync for kImportInRequiredESM. Otherwise require() of an ES
module with imports from a hooks module hit an internal assertion in
ModuleJobSync.syncLink().

Fixes: nodejs#66767
Refs: nodejs#62530
Signed-off-by: Matteo Collina <[email protected]>
@nodejs-github-bot

nodejs-github-bot commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Oct 15, 2026
@mcollina
mcollina requested a review from GeoffreyBooth October 15, 2026 16:13
@codecov

codecov Bot commented Oct 15, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.51%. Comparing base (1c90519) to head (eb35469).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66770      +/-   ##
==========================================
+ Coverage   90.49%   90.51%   +0.01%     
==========================================
  Files         797      797              
  Lines      277598   277602       +4     
  Branches    53336    53346      +10     
==========================================
+ Hits       251220   251271      +51     
+ Misses      16790    16733      -57     
- Partials     9588     9598      +10     
Files with missing lines Coverage Δ
lib/internal/modules/esm/loader.js 99.90% <100.00%> (+<0.01%) ⬆️

... and 34 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

GeoffreyBooth
GeoffreyBooth approved these changes Oct 16, 2026
View reviewed changes

@GeoffreyBooth GeoffreyBooth left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

RSLGTM.

I've been thinking it's time to remove the async hooks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina and joyeecheung reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
ShogunPanda
ShogunPanda approved these changes Oct 16, 2026
View reviewed changes
@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 16, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 16, 2026
@nodejs-github-bot

nodejs-github-bot commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/78427/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95 aduh95 mentioned this pull request Oct 16, 2026
[v26.x] Revert "module: synchronously load most ES modules" #66786
Closed
joyeecheung
joyeecheung approved these changes Oct 16, 2026
View reviewed changes

@joyeecheung joyeecheung left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Also +1 for removing module.register() soon-ish. module.registerHooks() has been adopted by several popular packages and it's been a while since we see bug reports. Although I think module.register() is only doc-deprecated currently, so maybe the next step is to runtime deprecate it first before removing it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mcollina mcollina added commit-queue PRs queued for automated landing through the Commit Queue. author ready PRs with CI started, the required approvals, and no outstanding review comments. and removed needs-ci PRs that need a full CI run. labels Oct 16, 2026
@nodejs-github-bot
nodejs-github-bot merged commit c526694 into nodejs:main Oct 17, 2026
82 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

Landed in c526694

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 17, 2026
@aduh95 aduh95 mentioned this pull request Oct 27, 2026
2026-10-28, Version 27.0.0-alpha.0.0.0 (Alpha) #67062
Merged
aduh95 pushed a commit that referenced this pull request Nov 12, 2026
@mcollina @aduh95
module: fix require(esm) on the module.register() hooks thread
473173c
On the async loader hooks thread, resolve kImportInRequiredESM and
kRequireInImportedCJS requests synchronously again, and always use
ModuleJobSync for kImportInRequiredESM. Otherwise require() of an ES
module with imports from a hooks module hit an internal assertion in
ModuleJobSync.syncLink().

Fixes: #66767
Refs: #62530
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: #66770
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
2026-11-30, Version 26.14.0 'Lithium' (LTS) #67664
Open
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@mcollina @gabylb
module: fix require(esm) on the module.register() hooks thread
c2ef006
On the async loader hooks thread, resolve kImportInRequiredESM and
kRequireInImportedCJS requests synchronously again, and always use
ModuleJobSync for kImportInRequiredESM. Otherwise require() of an ES
module with imports from a hooks module hit an internal assertion in
ModuleJobSync.syncLink().

Fixes: nodejs#66767
Refs: nodejs#62530
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: nodejs#66770
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ShogunPanda ShogunPanda ShogunPanda approved these changes
@GeoffreyBooth GeoffreyBooth GeoffreyBooth approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. esm Issues and PRs related to the ECMAScript Modules implementation.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

require(esm) inside a module.register() hook module fails with ERR_INTERNAL_ASSERTION in 26.12.0

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@mcollina @nodejs-github-bot @ShogunPanda @GeoffreyBooth @joyeecheung
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.