Skip to content

module: remove async module customization hooks - #67090

Open
GeoffreyBooth wants to merge 1 commit into
nodejs:mainfrom
GeoffreyBooth:remove-module-register
Open

GeoffreyBooth wants to merge 1 commit into
nodejs:mainfrom
GeoffreyBooth:remove-module-register

Conversation

@GeoffreyBooth

@GeoffreyBooth GeoffreyBooth commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

This should presumably land after the next amaro version bump on main. The bundled deps/amaro/dist/register-strip.mjs and register-transform.mjs still call module.register(). This PR should land after amaro is updated to a release that includes nodejs/amaro#497 (module.registerHooks).

Removes module.register() (DEP0205), the --experimental-loader and --loader flags, and the machinery that supported them: the loader hooks worker thread, the hooks proxy, the async module customization hook chains for resolving and loading, the internal worker class used to run the loader thread, and the asynchronous module job linking. Module customization is now provided only by module.registerHooks(), which runs synchronously on the thread that loads the modules.

  • The ES module loader always loads and links modules synchronously; the promise handling and the re-invented require() for imported CommonJS are gone. import() still defers evaluation to a later microtask.
  • worker_threads.isInternalThread is kept and always false; removing it is left for a semver-major change.
  • DEP0205 stays in deprecations.md as End-of-Life. ERR_ASYNC_LOADER_REQUEST_NEVER_SETTLED and ERR_LOADER_CHAIN_INCOMPLETE move to Legacy in errors.md.
  • Tests that only exercised the async hooks are removed; new tests cover require() after a failed import() and that import() does not evaluate the module before returning.
  • REPLACEME placeholders for the version are left for landing.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/loaders
  • @nodejs/test_runner
  • @nodejs/userland-migrations

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Oct 28, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@GeoffreyBooth
GeoffreyBooth force-pushed the remove-module-register branch from a98403b to 95c14fc Compare October 29, 2026 02:24
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@GeoffreyBooth
GeoffreyBooth force-pushed the remove-module-register branch 2 times, most recently from 6cea4a9 to 355da9b Compare October 30, 2026 02:44
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@GeoffreyBooth
GeoffreyBooth force-pushed the remove-module-register branch from 355da9b to aab37fe Compare October 30, 2026 03:23
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@GeoffreyBooth
GeoffreyBooth force-pushed the remove-module-register branch from aab37fe to ada3473 Compare October 30, 2026 04:57
@GeoffreyBooth
GeoffreyBooth marked this pull request as ready for review October 30, 2026 05:00
@GeoffreyBooth GeoffreyBooth added module Issues and PRs related to the module subsystem. esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders. labels Oct 30, 2026
@GeoffreyBooth
GeoffreyBooth force-pushed the remove-module-register branch from ada3473 to 937a866 Compare October 30, 2026 05:02
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Remove `module.register()` (DEP0205), the `--experimental-loader` and
`--loader` flags, and the machinery that supported them: the loader
hooks worker thread, the hooks proxy, the async module customization
hook chains for resolving and loading, the internal worker class used to
run the loader thread, and the asynchronous module job linking. Module
customization is now provided only by `module.registerHooks()`, which
runs synchronously on the thread that loads the modules.

As the loader thread no longer exists, the ES module loader always loads
and links modules synchronously, so the code that handled promises and
the re-invented `require()` for imported CommonJS customized by the
async module customization hooks is removed too. `import()` still defers
evaluation of the module to a later microtask, as before.

`worker_threads.isInternalThread` is kept for compatibility and is now
always `false`; removing it is left for a future semver-major change.

The `ERR_ASYNC_LOADER_REQUEST_NEVER_SETTLED` and
`ERR_LOADER_CHAIN_INCOMPLETE` error codes are no longer used and are
documented as removed.

Tests that exist only to exercise the async module customization hooks
are removed.

Assisted-by: Claude
Signed-off-by: Geoffrey Booth <webadmin@geoffreybooth.com>
@GeoffreyBooth
GeoffreyBooth force-pushed the remove-module-register branch from 937a866 to a825144 Compare October 30, 2026 05:15
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.54015% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.65%. Comparing base (d699704) to head (a825144).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/node_watchdog.cc 0.00% 0 Missing and 1 partial ⚠️
src/node_worker.cc 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67090      +/-   ##
==========================================
- Coverage   90.67%   90.65%   -0.02%     
==========================================
  Files         797      794       -3     
  Lines      278791   276730    -2061     
  Branches    53617    53319     -298     
==========================================
- Hits       252794   250878    -1916     
+ Misses      16356    16203     -153     
- Partials     9641     9649       +8     
Files with missing lines Coverage Δ
lib/internal/bench_runner/cli.js 94.15% <ø> (-0.01%) ⬇️
lib/internal/errors.js 98.80% <100.00%> (-0.01%) ⬇️
lib/internal/main/eval_string.js 79.48% <100.00%> (ø)
lib/internal/main/worker_thread.js 94.87% <100.00%> (-0.24%) ⬇️
lib/internal/modules/customization_hooks.js 100.00% <100.00%> (ø)
lib/internal/modules/esm/load.js 95.54% <100.00%> (-1.27%) ⬇️
lib/internal/modules/esm/loader.js 99.56% <100.00%> (-0.35%) ⬇️
lib/internal/modules/esm/module_job.js 100.00% <100.00%> (+0.41%) ⬆️
lib/internal/modules/esm/module_map.js 98.48% <100.00%> (+0.01%) ⬆️
lib/internal/modules/esm/translators.js 97.42% <100.00%> (-0.21%) ⬇️
... and 14 more

... and 33 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

esm Issues and PRs related to the ECMAScript Modules implementation. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. loaders Issues and PRs related to ES module loaders. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants