Repository navigation
module: remove async module customization hooks - #67090
GeoffreyBooth wants to merge 2 commits into
Conversation
|
Review requested:
|
a98403b to
95c14fc
Compare
6cea4a9 to
355da9b
Compare
355da9b to
aab37fe
Compare
aab37fe to
ada3473
Compare
ada3473 to
937a866
Compare
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>
937a866 to
a825144
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67090 +/- ##
==========================================
- Coverage 90.67% 90.65% -0.02%
==========================================
Files 797 794 -3
Lines 278777 276716 -2061
Branches 53610 53307 -303
==========================================
- Hits 252782 250866 -1916
+ Misses 16343 16199 -144
+ Partials 9652 9651 -1
🚀 New features to boost your workflow:
|
|
since it's simplify loading phase, it's there are an positive impact in term of perf ? |
|
I think this should be treated as semver major due to the large impact |
I ran Node’s
So there’s no regression, and at most a small gain in the import path, because loading no longer has to check for async hooks. The larger win is for hook users. In a separate hyperfine run, a script using benchmark results (
|
| Scenario | Before | After |
|---|---|---|
node -e 0 |
99.1 ± 5.0 ms | 99.0 ± 5.7 ms |
| ESM entry (three modules) | 107.1 ± 7.7 ms | 105.6 ± 5.6 ms |
| CJS entry | 104.8 ± 4.3 ms | 103.1 ± 4.6 ms |
The removal mainly benefits hook users. A script using module.register() async hooks took about 141 ms, versus about 107 ms with the equivalent registerHooks() (about 24% faster). That gain comes from the sync API, which is already on main.
|
@marco-ippolito I’m happy for this to land only in the 27 line with I’d still argue it isn’t semver-major in the policy sense, because
We also went well beyond what an experimental API requires. After the discussion in #62395 (e.g. “experimental status is already a warning”, and the concerns about existing adoption), we shipped a docs-only deprecation in v25.9.0/v24.15.0 (#62395) and a runtime deprecation in v26.0.0 (#62401). Users have had a full major of runtime warnings, and the plan to remove in 27 has been on record since #62401. |
Removes
module.register()(DEP0205), the--experimental-loaderand--loaderflags, 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 bymodule.registerHooks(), which runs synchronously on the thread that loads the modules.require()for imported CommonJS are gone.import()still defers evaluation to a later microtask.worker_threads.isInternalThreadis kept and alwaysfalse; removing it is left for a semver-major change.deprecations.mdas End-of-Life.ERR_ASYNC_LOADER_REQUEST_NEVER_SETTLEDandERR_LOADER_CHAIN_INCOMPLETEmove to Legacy inerrors.md.require()after a failedimport()and thatimport()does not evaluate the module before returning.REPLACEMEplaceholders for the version are left for landing.