node/lib
Joyee Cheung 3e31baeda6
esm: use sync loading/resolving on non-loader-hook thread
ESM resolution and loading is now always synchronous from a
non-loader-hook thread. If no asynchrnous loader hooks are
registered, the resolution/loading is entirely synchronous.
If asynchronous loader hooks are registered, these would be
synchronous on the non-loader-hook thread, and asynchronous
on the loader hook thread.

This avoids several races caused by async/sync loading sharing
the same cache. In particular, asynchronous loader hooks
now works with `require(esm)` - previously it tends to break
due to races.

In addition, when an asynchronous loader hook
returns a promise that never settles, the main thread no longer
silently exits with exit code 13, leaving the code below
any module loading calls silently ignored without being executed.
Instead, it now throws ERR_ASYNC_LOADER_REQUEST_NEVER_SETTLED
which can be caught and handled by the main thread. If the module
request comes from `import()`, the never-settling promise is
now relayed to the result returned by `import()`.

Drive-by: when annotating the error about importing undetectable
named exports from CommonJS, it now no longer reload the source
code of the CommonJS module, and instead reuses format information
cached when the module was loaded for linking.

PR-URL: https://github.com/nodejs/node/pull/60380
Fixes: https://github.com/nodejs/node/issues/59666
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2025-10-31 20:45:10 +00:00
..
assert
dns dns: make promise API fully constructed from lib/internal/dns/promises 2022-06-20 19:58:45 +01:00
fs
inspector lib: revert to using default derived class constructors 2025-08-30 14:28:10 +00:00
internal esm: use sync loading/resolving on non-loader-hook thread 2025-10-31 20:45:10 +00:00
path
readline lib: revert to using default derived class constructors 2025-08-30 14:28:10 +00:00
stream stream: add pipeline() for webstreams 2023-02-02 19:45:42 +00:00
test test_runner: do not expose internal loader 2024-08-13 15:17:50 +02:00
timers lib: remove unnecessary optional chaining 2024-11-07 15:59:12 +00:00
util
_http_agent.js http: add Agent.agentKeepAliveTimeoutBuffer option 2025-08-13 02:32:30 +00:00
_http_client.js http: fix http client leaky with double response 2025-10-13 15:58:26 +00:00
_http_common.js http: fix http client leaky with double response 2025-10-13 15:58:26 +00:00
_http_incoming.js http: add optimizeEmptyRequests server option 2025-10-14 12:17:53 +00:00
_http_outgoing.js http: lazy allocate cookies array 2025-10-27 14:01:06 +00:00
_http_server.js http: add optimizeEmptyRequests server option 2025-10-14 12:17:53 +00:00
_stream_duplex.js lib: add module to use in module deprecation warnings 2025-05-26 14:39:25 +00:00
_stream_passthrough.js lib: add module to use in module deprecation warnings 2025-05-26 14:39:25 +00:00
_stream_readable.js lib: add module to use in module deprecation warnings 2025-05-26 14:39:25 +00:00
_stream_transform.js lib: add module to use in module deprecation warnings 2025-05-26 14:39:25 +00:00
_stream_wrap.js lib: add module to use in module deprecation warnings 2025-05-26 14:39:25 +00:00
_stream_writable.js lib: add module to use in module deprecation warnings 2025-05-26 14:39:25 +00:00
_tls_common.js lib: add module to use in module deprecation warnings 2025-05-26 14:39:25 +00:00
_tls_wrap.js lib: add module to use in module deprecation warnings 2025-05-26 14:39:25 +00:00
assert.js assert: allow printf-style messages as assertion error 2025-10-17 20:15:17 +00:00
async_hooks.js async_hooks: move asyncResource property on bound function to EOL 2025-06-09 15:20:30 +00:00
buffer.js meta: enable jsdoc/check-tag-names rule 2025-07-18 09:28:21 +00:00
child_process.js lib: use validators for argument validation 2025-09-21 02:47:14 +00:00
cluster.js cluster: use ObjectPrototypeHasOwnProperty 2023-05-25 16:04:19 +00:00
console.js
constants.js
crypto.js crypto: support ML-KEM, DHKEM, and RSASVE key encapsulation mechanisms 2025-08-20 14:30:58 +00:00
dgram.js dgram: restore buffer optimization in fixBufferList 2025-09-21 17:50:41 +00:00
diagnostics_channel.js diagnostics_channel: fix race condition with diagnostics_channel and GC 2025-09-19 07:28:39 +00:00
dns.js dns: move falsy hostname in lookup to end-of-life 2025-06-13 12:47:23 +00:00
domain.js domain: remove deprecated API call 2025-08-05 03:51:16 +00:00
eslint.config_partial.mjs lib: expose global ErrorEvent 2025-08-18 08:14:54 +00:00
events.js lib: prefer AsyncIteratorPrototype primordial 2025-07-29 21:54:16 +00:00
fs.js fs: port SonicBoom module to fs module as Utf8Stream 2025-07-28 20:27:07 -07:00
http.js http: expose websockets 2024-07-08 15:55:43 +00:00
http2.js http2: add server handshake utility 2024-01-12 16:09:48 +00:00
https.js http,https: handle IPv6 with proxies 2025-09-22 23:19:26 +00:00
inspector.js inspector: initial support websocket inspection 2025-08-19 10:09:14 +00:00
module.js lib: allow skipping source maps in node_modules 2025-01-23 22:44:10 +00:00
net.js lib: make ERM functions into wrappers returning undefined 2025-05-25 13:44:43 +00:00
os.js meta: enable jsdoc/check-tag-names rule 2025-07-18 09:28:21 +00:00
path.js path: refactor path joining logic for clarity and performance 2025-09-08 18:44:18 +00:00
perf_hooks.js perf_hooks: move non-standard performance properties to perf_hooks 2025-10-28 00:23:50 +01:00
process.js src: disambiguate terms used to refer to builtins and addons 2022-08-09 01:36:49 +08:00
punycode.js punycode: limit deprecation warning 2025-01-18 18:01:54 +00:00
querystring.js meta: enable jsdoc/check-tag-names rule 2025-07-18 09:28:21 +00:00
quic.js quic: continue working on quic api bits 2025-10-07 14:04:53 +00:00
readline.js lib: prefer logical assignment 2024-10-09 06:42:16 +00:00
repl.js repl: move completion logic to internal module 2025-10-08 07:37:22 +00:00
sea.js sea: implement sea.getAssetKeys() 2025-09-04 11:58:50 +00:00
sqlite.js sqlite: cleanup ERM support and export Session class 2025-05-30 17:21:30 -07:00
stream.js stream: change stream to use index instead of for...of 2024-08-23 07:31:55 +00:00
string_decoder.js meta: enable jsdoc/check-tag-names rule 2025-07-18 09:28:21 +00:00
sys.js lib: add node: prefix in sys module deprecation warning 2025-05-26 14:39:25 +00:00
test.js test_runner: add assert.register() API 2025-01-04 18:30:04 +00:00
timers.js lib: remove redundant destroyHook checks 2025-10-08 12:11:43 +00:00
tls.js tls: only do off-thread certificate loading on loading tls 2025-09-18 18:54:14 +00:00
trace_events.js trace_events: use private fields instead of symbols for Tracing 2023-12-28 23:20:22 +00:00
tty.js tty: initialize winSize array with values 2024-08-11 06:32:13 +00:00
url.js url: replaced slice with at 2025-09-14 00:39:32 +00:00
util.js lib: fix constructor in _errnoException stack tree 2025-10-13 14:25:09 +00:00
v8.js v8: add cpu profile 2025-10-11 17:20:57 +00:00
vm.js lib: add validation for options in compileFunction 2024-12-06 06:53:06 +00:00
wasi.js lib: expose setupInstance method on WASI class 2025-07-07 08:41:16 -07:00
worker_threads.js worker: add name for worker 2025-08-05 13:45:41 +00:00
zlib.js zlib: add dictionary support to zstdCompress and zstdDecompress 2025-08-04 16:13:57 +00:00