Skip to content

module: remove async module customization hooks - #67090

Draft
GeoffreyBooth wants to merge 2 commits into
nodejs:mainfrom
GeoffreyBooth:remove-module-register
Draft

GeoffreyBooth wants to merge 2 commits into
nodejs:mainfrom
GeoffreyBooth:remove-module-register

Conversation

@GeoffreyBooth

@GeoffreyBooth GeoffreyBooth commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Stacked on #67074. The first commit (test: use registerHooks() over module.register()) is that PR; please review only the second commit, module: remove async module customization hooks: 95c14fc (the diff will shrink to one commit once it lands).

Blocked on the amaro bump. The bundled deps/amaro/dist/register-strip.mjs and register-transform.mjs still call module.register(). This must land after amaro is updated to a release that includes nodejs/amaro#497 (module.registerHooks). Opened as a draft to start the clock.

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; a new test covers require() after a failed import().
  • REPLACEME placeholders (version, PR URL) are left for landing.

Port the tests that registered async module customization hooks, via
`--loader`, `--experimental-loader` or `module.register()`, only as a
means of exercising other features to use `module.registerHooks()`
instead. This keeps the coverage for those features independent of the
async module customization hooks, which are being removed.

Tests that exist only to exercise the async module customization hooks
themselves are left as they are.

Assisted-by: Claude
Signed-off-by: Geoffrey Booth <webadmin@geoffreybooth.com>
@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

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 a98403b to 95c14fc Compare October 29, 2026 02:24
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

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

Labels

lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants