node/lib/internal
Filip Skokan 1c16b45d35
lib: refactor internal webidl converters
Rework lib/internal/webidl.js into a documented shared converter module
that follows the Web IDL conversion algorithms more closely.

Improvements:
- Add documented converters and helper factories for primitive values,
  dictionaries, enums, sequences, interfaces, required arguments,
  integers, `Uint8Array`, and `BufferSource`.
- Move WebCrypto onto the shared converters, while keeping compatibility
  wrappers for its existing `BufferSource` and `BigInteger` behavior.
- Use shared converters from Blob, Performance, Web Locks, and
  structured clone option handling.
- Add benchmarks for `ConvertToInt` and WebCrypto Web IDL converter hot
  paths.
- Add focused tests for core converters, WebCrypto converters, integer
  conversion, and buffer source behavior.

Fixes:
- Make the shared `BufferSource` and `Uint8Array` converters reject
  resizable `ArrayBuffer` and growable `SharedArrayBuffer` backing
  stores unless explicitly allowed. WebCrypto preserves its legacy
  resizable backing-store behavior through compatibility wrappers until
  a semver-major follow-up can opt in to the stricter behavior.
- Use Web IDL `ToNumber` and `ToString` behavior for BigInt, Symbol, and
  object primitive conversion.
- Use exact BigInt modulo for 64-bit `ConvertToInt` wrapping and
  document the final Number approximation behavior.
- Normalize mathematical modulo results to `+0` where Web IDL requires
  it.
- Process inherited dictionaries in least-derived to most-derived order,
  sorting members only within each dictionary level.
- Use `IteratorComplete` truthiness for sequence conversion.
- Cover detached buffers, resizable-backed views, growable-backed views,
  cross-realm buffer sources, mutation-after-call behavior, inherited
  dictionary member order, and sequence iterator completion behavior.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62979
Backport-PR-URL: https://github.com/nodejs/node/pull/63563
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-06-23 01:06:46 +01:00
..
assert assert: use a set instead of an array for faster lookup 2026-01-19 19:19:27 +01:00
async_local_storage
bootstrap quic: move quic behind compile time flag 2026-05-07 17:32:44 +02:00
child_process child_process: treat ipc length header as unsigned uint32 2026-01-27 22:52:28 +01:00
cluster lib: prefer call() over apply() if argument list is not array 2026-02-22 23:16:05 +01:00
console console: optimize single-string logging 2025-11-13 22:44:17 +01:00
crypto lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
debugger debugger: add --help to node inspect and improve docs 2026-06-18 00:15:51 +02:00
dns dns,net: reject hostnames with embedded NUL bytes 2026-06-17 20:02:06 +02:00
encoding lib: fix typo idenity => identity 2026-06-18 00:15:52 +02:00
errors lib: add source map support for assert messages 2025-09-12 16:39:07 +02:00
events
fs fs: make Date properties on Stats enumerable 2026-06-18 00:15:54 +02:00
http2 http2: emit session close before stream close 2026-06-18 21:12:35 +01:00
inspector inspector: coerce key and value to string in webstorage events 2026-05-09 09:32:20 +02:00
legacy
main watch: fix --env-file-if-exists crashing on linux if the file is missing 2026-05-07 15:41:38 +02:00
modules module: load ESM helpers eagerly in the snapshot 2026-06-18 21:12:36 +01:00
per_context perf_hooks: fix stack overflow error 2025-11-18 13:16:10 +01:00
perf lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
process permission: handle process.chdir on writereport 2026-06-17 20:02:05 +02:00
quic crypto: harden KeyObject internal slots 2026-06-23 01:06:39 +01:00
readline repl: fix pasting after moving the cursor to the left 2025-11-13 22:44:20 +01:00
repl repl: fix dedup comparing normalized line against raw history 2026-06-18 00:15:53 +02:00
source_map lib: fix source map url parse in dynamic imports 2026-04-10 14:52:18 +02:00
streams stream: switch to internal sleep binding 2026-06-18 21:12:36 +01:00
test
test_runner test_runner: dont buffer unordered events in process isolation mode 2026-06-18 21:12:33 +01:00
tls tls: add unsupported renegotiation error 2026-06-18 00:15:50 +02:00
util crypto: harden KeyObject internal slots 2026-06-23 01:06:39 +01:00
v8 lib: avoid quadratic shift() in startup snapshot callback 2026-05-07 15:41:47 +02:00
vm lib: prefer call() over apply() if argument list is not array 2026-02-22 23:16:05 +01:00
watch_mode watch: fix --env-file-if-exists crashing on linux if the file is missing 2026-05-07 15:41:38 +02:00
webstreams stream: fix Writable.toWeb() hang on synchronous drain 2026-06-18 21:12:33 +01:00
worker lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
abort_controller.js lib: defer AbortSignal.any() following 2026-05-07 15:41:32 +02:00
assert.js
async_context_frame.js
async_hooks.js async_hooks: enabledHooksExist shall return if hooks are enabled 2026-04-08 23:53:00 +02:00
blob.js lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
blocklist.js
buffer.js buffer: disallow ArrayBuffer transfer on pooled buffer 2026-04-08 23:53:00 +02:00
child_process.js child_process: add tracing channel for spawn 2026-04-10 14:52:12 +02:00
cli_table.js
constants.js
data_url.js
dgram.js
encoding.js lib: use utf8 fast path for streaming TextDecoder 2026-02-22 23:16:14 +01:00
error_serdes.js
errors.js tls: add unsupported renegotiation error 2026-06-18 00:15:50 +02:00
event_target.js events: remove redundant todo 2026-01-27 22:52:28 +01:00
file.js lib: prefer call() over apply() if argument list is not array 2026-02-22 23:16:05 +01:00
fixed_queue.js lib: recycle queues 2026-02-22 23:16:13 +01:00
freelist.js
freeze_intrinsics.js
heap_utils.js
histogram.js
http.js lib,test: redact proxy credentials in tunnel errors 2026-06-17 20:02:05 +02:00
inspector_async_hook.js async_hooks: add trackPromises option to createHook() 2026-02-22 23:16:12 +01:00
inspector_network_tracking.js
js_stream_socket.js
linkedlist.js
locks.js lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
mime.js util: optimize toASCIILower function using V8s native toLowerCase 2026-01-19 19:19:30 +01:00
navigator.js
net.js tls: forward keepAlive, keepAliveInitialDelay, noDelay to socket 2026-04-10 14:52:15 +02:00
options.js doc: fix node-config-schema 2026-05-07 18:14:56 +02:00
priority_queue.js lib: optimize priority queue 2025-10-06 16:27:09 +02:00
promise_hooks.js
querystring.js
README.md
repl.js
socket_list.js
socketaddress.js lib: enforce use of URLParse 2026-01-19 19:19:22 +01:00
stream_base_commons.js
timers.js lib: remove redundant destroyHook checks 2025-11-07 18:11:13 +01:00
trace_events_async_hooks.js
tty.js
url.js url: optimize URLSearchParams set/delete duplicate handling 2026-05-07 15:41:46 +02:00
util.js util: remove unused functions 2026-06-18 21:12:37 +01:00
v8_prof_polyfill.js src: build v8 tick processor as built-in source text modules 2026-04-08 23:52:58 +02:00
validators.js lib: fixes validator message 2026-06-18 00:15:52 +02:00
vm.js lib: prefer call() over apply() if argument list is not array 2026-02-22 23:16:05 +01:00
wasm_web_api.js
watchdog.js
webidl.js lib: refactor internal webidl converters 2026-06-23 01:06:46 +01:00
webstorage.js inspector: auto collect webstorage data 2026-05-09 09:32:20 +02:00
worker.js watch: track worker entry files in watch mode 2026-05-07 15:41:48 +02:00

Internal Modules

The modules located in lib/internal directory are exclusively meant for internal usage within the Node.js core. They are not intended to be accessed via user modules require(). These modules may change at any point in time. Relying on these internal modules outside the core is not supported and can lead to unpredictable behavior.

In certain scenarios, accessing these internal modules for debugging or experimental purposes might be necessary. Node.js provides the --expose-internals flag to expose these modules to userland code. This flag only exists to assist Node.js maintainers with debugging internals. It is not meant for use outside the project.