Commit Graph
12854 Commits
Author SHA1 Message Date
James M Snell 4d95cec69b perf_hooks: add CBOR export/import for histogram exchange
Provide a binary export/import mechanism for histograms.

Since there is no standard interchange format for histograms,
using CBOR is meant to make the format as platform/runtime
agnostic as possible while producing a compact/efficient
result. No new dependency is introduced, we just encode
the CBOR directly.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus
PR-URL: https://github.com/nodejs/node/pull/65434
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-08-26 02:28:31 +00:00
JunHwan Choi 96b12934a2 lib: use validateArray for array arguments
Three call sites still duplicated the ArrayIsArray check that
validateArray already performs. Both files were already importing other
validators next to these checks. The error code, argument name and
expected type are unchanged, so the thrown error stays identical.

The ArrayIsArray primordial is no longer used in histogram.js and is
dropped from its destructuring; blocklist.js still uses it elsewhere.

The existing tests only asserted the error code, so assertions covering
the full error message are added for all three call sites. They pass
both before and after this change.

Refs: https://github.com/nodejs/node/pull/64959
Assisted-by: claude:fable-5
Signed-off-by: JunHwan Choi <devjunsday@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65344
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-08-25 16:57:32 -07:00
Filip Skokan e7a69c4992 crypto: discover ciphers from OpenSSL providers
Enumerate usable ciphers and aliases from activated OpenSSL 3 providers
instead of maintaining lists of provider-only algorithms. Skip numeric
OID aliases and filter NULL, TLS composite, multiblock, and
encrypt-then-MAC implementations that the Cipher APIs cannot use.
Preserve the OpenSSL 1.1.1 and BoringSSL paths.

Expose CBC-CTS, SM4-GCM, SM4-CCM, SM4-XTS, and additional AES key wrap
implementations. Add `ctsMode` (CS1/CS2/CS3) and `xtsStandard`
(GB/IEEE) options for selecting provider CTS and SM4-XTS variants.

Keep ordinary cipher construction on the original binding and legacy
lookup paths.

Lazily cache successful provider fetches per Environment for
string initialization and `getCipherInfo()`.
Index entries by case-insensitive query, canonical, and alias names.
Deduplicate owners by provider and canonical identity. Return borrowed
pointers on warm hits.

Use the shared process-wide FIPS-state generation to invalidate
per-Environment cipher caches and refresh `getCiphers()` snapshots in
the main thread and workers. Existing cipher contexts retain their
implementation and can finish across a transition. Release provider
owners before unloading worker addon DSOs.

Enforce one-shot updates for CBC-CTS, AES key wrap, SIV/GCM-SIV, and
CCM decryption. Reject finalization without required input or CCM tags,
and defer authentication failures to `final()`. Document streaming and
XTS data-unit constraints.

Add known-answer vectors, option validation, provider round trips,
cache, worker, snapshot, FIPS transition, and construction benchmark
coverage.

Fixes: https://github.com/nodejs/node/issues/43040
Fixes: https://github.com/nodejs/node/issues/64866
Refs: https://github.com/nodejs/node/issues/62982
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65484
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-08-25 23:11:06 +00:00
Filip Skokan 025e88f981 crypto: discover hashes from OpenSSL providers
Enumerate usable digests and aliases from activated OpenSSL 3 providers
rather than relying only on the legacy digest registry. Normalize
provider aliases, omit numeric OIDs and NULL, and validate them against
the active default property query. Preserve legacy names and the OpenSSL
1.1.1 and BoringSSL paths.

Expose KECCAK-KMAC-128, KECCAK-256, SHA256-192, and other provider
digests. Add `functionName` and `customization` options for cSHAKE
digests in `createHash()` and `crypto.hash()` with OpenSSL 4.0 or later.

Resolve provider-only digest names across hashing, HMAC, KDF, signing,
verification, and RSA digest options. Keep ordinary hash construction
and one-shot hashing on the original binding arities and direct
initialization paths. Use parameterized setup only when cSHAKE options
are supplied.

Lazily cache successful provider fetches per Environment.
Index entries by case-insensitive query, canonical, and alias names.
Deduplicate owners by provider and canonical identity. Return borrowed
pointers on warm hits.

Introduce a process-wide FIPS-state generation that advances only after
successful, state-changing `setFips()` calls. Use it to invalidate
per-Environment digest caches and refresh `getHashes()` snapshots in the
main thread and workers. Keep cache IDs monotonic across invalidation
because JavaScript Realms can retain them. Existing hash contexts can
finish across a transition.

Release provider owners before unloading worker addon DSOs. Document
provider-dependent availability and operation-specific restrictions.
Add known-answer vectors, option validation, provider resolution,
property-query, FIPS transition, worker, snapshot, and cross-API
coverage.

Refs: https://github.com/nodejs/node/issues/62982
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65484
Fixes: https://github.com/nodejs/node/issues/43040
Fixes: https://github.com/nodejs/node/issues/64866
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-08-25 23:11:05 +00:00
Filip Skokan 7aaf9b44d7 crypto: avoid throwing CryptoKey brand checks
Use the native CryptoKey FunctionTemplate brand check instead of
probing slot access and catching ERR_INVALID_THIS. Keep a private-field
fast path for ordinary same-realm CryptoKeys.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65503
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-08-25 17:19:35 +00:00
Filip Skokan ebd88be3dd crypto: avoid throwing KeyObject brand checks
Use the native KeyObject FunctionTemplate brand check instead of
probing slot access and catching ERR_INVALID_THIS. Keep a private-field
fast path for ordinary same-realm KeyObjects.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65503
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-08-25 17:19:34 +00:00
Chiang Fong Lee f17088855f doc: fix return types for sync methods
For the sync methods spawnSync(), execSync() and execFileSync(), when
the stdio option is set to anything other than 'pipe', the stdout and
stderr returned from the C++ code will be null, and not a string or
Buffer as currently documented.

PR-URL: https://github.com/nodejs/node/pull/58575
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-08-25 11:29:02 +02:00
Szymon Łągiewka 984e46f322 events: inline iterationCondition hybrid dispatch closure
While more readable, the removed closure overhead unlocks 10-20% in
eventtarget.js benchmark.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/64473
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2026-08-25 07:53:50 +00:00
Szymon Łągiewka 59dd75b93b events: inline createEvent hybrid dispatch closure
Originally added in 16b11cd2ad, it first
had three callers. Now there's only one branch requireing it.

Signed-off-by: Szymon Łągiewka <slagiewka@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/64473
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2026-08-25 07:53:48 +00:00
Shelley Vohr e618b1b092 fs: stop stat()ing every entry in recursive readdir
readdir({ recursive: true }) asked the binding for names only and then
called internalModuleStat() on every entry to find the directories to
descend into; with withFileTypes it built the Dirents and still stat()ed
every entry that was not already a directory. Both variants also ran
path.join() and path.relative() per entry to build the relative result.

Ask the binding for file types in all cases, descend into directories
directly, and only stat() symbolic links and entries of unknown type
(which is what could point to a directory). The relative name is the
parent's prefix plus the entry name. Results, their order and the
symlink-following behavior are unchanged for fs.readdirSync, fs.readdir
and fs.promises.readdir.

The known_issues test for Buffer paths (#58892) called back without
checking the error; the error now reaches the callback instead of being
thrown from the completion handler, so the test asserts success to keep
expressing the issue.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65487
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-08-25 07:53:37 +00:00
Trivikram Kamat 4b5e86c4e2 stream: normalize fused stateless transform results
Normalize each stateless transform result before passing it to
the next transform in a fused run. This ensures that subsequent
transforms always receive Uint8Array[] batches in both synchronous
and asynchronous pipelines.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/65367
Fixes: https://github.com/nodejs/node/issues/65366
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-08-25 02:52:18 +00:00
Matteo Collina f2c7f1bcf8 stream: encode whole chunks in TextEncoderStream
The encode-and-enqueue transform walked the chunk code unit by code
unit, materializing a single-character string per index and building
the output with string concatenation. The only state that crosses
chunks is a trailing high (leading) surrogate, and TextEncoder.encode's
USVString conversion already replaces every interior lone surrogate
with U+FFFD, which is exactly what the spec loop produces. Join a
pending high surrogate with the incoming chunk, hold back a new
trailing high surrogate, and encode the rest in a single native call.

The streaming decode path also reuses a single options object instead
of allocating { stream: true } per chunk.

An encoding-streams benchmark is added since the suite had no
TextEncoderStream/TextDecoderStream row. Encoding improves by ~546%
with 1KB string chunks and ~20% with 16-character chunks; decode is
unchanged.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65414
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Mattias Buelens <mattias@buelens.com>
2026-08-24 18:17:10 +00:00
Hamid Reza Ghavami f509cf1d08 util: allow single-line format when break length is infinite
Signed-off-by: Hamid Reza Ghavami <hamidr.ghavami@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64238
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2026-08-24 14:31:34 +00:00
Sankalp Thakur 278ead184f tls: throw on invalid ALPNProtocols instead of aborting
tls.connect() with malformed ALPNProtocols hit
CHECK_EQ(0, SSL_set_alpn_protos(...)) in the C++ layer and aborted
the process with SIGABRT.

Validate in JS instead, in convertALPNProtocols, so both client and
server fail early with a recoverable ERR_INVALID_ARG_VALUE:

- zero-length string protocols now throw from convertProtocols
- wire-format buffers are checked for zero-length and truncated
  entries
- an empty buffer or array is still accepted and means skip ALPN,
  matching the historical behavior for []

The C++ CHECK_EQ is left unchanged: once JS has validated the input,
a non-zero SSL_set_alpn_protos return is an internal invariant
failure rather than user-facing input.

Fixes: https://github.com/nodejs/node/issues/65069

Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65076
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-24 14:31:20 +00:00
Tim Perry 214cf0693b http: improve performance with known-length calls to end()
This boosts RPS performance for the common API case where you call
`res.end(data)` with the entire response by up to 9%.

Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65466
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-08-24 09:54:15 +00:00
Jason Zhang 2dbf9d733e fs: fix realpath of namespaced drive paths
The JavaScript realpath implementation probes a namespaced drive root
through the fs binding. Windows path resolution drops the trailing
separator from that probe, so lstat receives C: and reports EISDIR.

Use the regular drive-root spelling only for the probe. Preserve the
namespaced spelling for traversal and returned paths.

Signed-off-by: Jason Zhang <xzha4350@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65378
Fixes: https://github.com/nodejs/node/issues/62446
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
2026-08-24 04:26:04 +00:00
Dushyant Singh HadaandCursor 5b316e5402 util: fix OSC 8 hyperlink stripping in stripVTControlCharacters
The bundled ansi-regex OSC pattern used a restrictive URI
character class that failed when URIs contained RFC 3986-valid
characters such as parentheses.

Match OSC sequences generically as ESC ] ... ST, aligned with
ansi-regex v6.2.0.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: dushyant <dushyanthada90@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64319
Fixes: https://github.com/nodejs/node/issues/64313
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-24 03:14:23 +00:00
Trivikram Kamat f96dccc271 stream: prevent share from eagerly draining source
Wait for buffer space after drop-newest discards an upstream result.
This keeps one consumer pull from draining the source or looping
indefinitely while a slower consumer keeps the buffer full.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/65338
Fixes: https://github.com/nodejs/node/issues/65337
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-08-23 21:43:31 +00:00
Antoine du Hamel 057e591f7c lib,src: remove --no-experimental-websocket CLI flag
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65284
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-08-23 21:16:19 +00:00
Mert Can Altin 00c80a8572 fs: abort in-flight stat operations
Signed-off-by: Mert Can Altin <mertgold60@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63143
Refs: https://github.com/nodejs/node/pull/57775
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-08-23 20:29:59 +00:00
James M Snell 524dee4372 perf_hooks: add statistical hypothesis testing to histogram
Welch's t-test, Mann-Whitney U test, Cohen's d, and Cliff's delta,
and and handful of others

These methods enable in-process benchmark comparison and regression
detection without external dependencies.

No new dependencies.

Tests and docs created by the AI agent.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus
PR-URL: https://github.com/nodejs/node/pull/65416
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-08-23 20:29:19 +00:00
Kamat, Trivikram c28857e64c stream: drain pending writes before broadcast end
Keep processing writes that were queued before end(). Signal the
broadcast end only after those writes enter the shared buffer.

Resolve end() after all consumers reach end-of-stream. This prevents
backpressured writes from remaining pending forever.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/65334
Fixes: https://github.com/nodejs/node/issues/65333
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-08-23 13:25:30 -07:00
Mhayk Whandson 453f47acda repl: keep entries added while history file is loading
Lines can be evaluated while the history file is still being read
asynchronously by setupHistory(), e.g. when the input stream does not
support pausing. The entries added to the in-memory history in the
meantime were discarded once the file load completed, because the
loaded entries overwrote the in-memory history. Merge the persisted
entries with the in-memory ones instead.

Refs: https://github.com/nodejs/node/issues/64508
Signed-off-by: Mhayk Whandson <hi@mhayk.com>
PR-URL: https://github.com/nodejs/node/pull/64513
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-23 17:29:01 +00:00
Samuel Williams 0b89f8fe47 tty: add raw-vt and io raw modes
Signed-off-by: Samuel Williams <samuel.williams@shopify.com>
PR-URL: https://github.com/nodejs/node/pull/64140
Refs: https://github.com/nodejs/node/issues/63059
Refs: https://github.com/libuv/libuv/issues/32
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-23 15:52:12 +00:00
semimikoh 22e99dc2f1 test_runner: match dotfiles in default coverage exclude
The default coverage exclude globs did not match dotfiles, so test
files such as `test/.foo.test.js` were incorrectly included in coverage
reports. Apply the `dot: true` minimatch option when matching the
relative path so the default exclude patterns cover dotfiles, while
keeping plain matching for the absolute path to avoid misinterpreting
dot segments in the filesystem path (e.g. tmp dirs like `test/.tmp.0`).

Fixes: https://github.com/nodejs/node/issues/63397
Signed-off-by: semimikoh <ejffjeosms@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63401
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-08-23 15:40:58 +00:00
Antoine du Hamel 220ee76146 tools: fix the list of globals in ESLint config files
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65281
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-08-23 17:09:16 +02:00
Shelley Vohr 65f518c72a module: add a read-only mode to the compile cache
A compile cache generated ahead of time and shipped inside an
application package should only ever be read: the package may be
immutable or covered by an integrity check, and a cache directory that
appears at run time would be a surprise. Add readOnly to
module.enableCompileCache() and NODE_COMPILE_CACHE_READONLY=1: existing
entries are loaded as before, nothing is serialized or persisted,
flushCompileCache() is a no-op, and the cache directory is used as found
rather than created, so enabling against a missing directory fails
instead of making one.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65302
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-08-23 08:14:37 +00:00
Srinu desettiandsemimikoh 0ea2c86b5b fs: fix glob early return skipping sibling entries
The children loop in the glob traversal returned from the whole method
when a child path had already been seen through a different pattern
context, silently dropping the remaining sibling entries. Whether this
triggered depended on directory iteration order, which also made
test-fs-glob.mjs flaky.

Remove the check: the cache.add call at the start of the traversal
already prevents reprocessing.

Fixes: https://github.com/nodejs/node/issues/62897
Co-authored-by: semimikoh <ejffjeosms@gmail.com>
Signed-off-by: webdevelopersrinu <webdeveloper.srinu9@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64895
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-23 05:34:20 +00:00
James M Snell c1d3132a1e quic: mark drain promise handled
Fixes: https://github.com/nodejs/node/issues/64290
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus
PR-URL: https://github.com/nodejs/node/pull/65319
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2026-08-23 03:53:29 +00:00
Yagiz Nizipli 130fe365b9 url: speed up WHATWG URL parsing
Parse one-byte ASCII inputs in place instead of copying them into a
UTF-8 buffer, and reuse the original V8 string when the serialized
href is unchanged. Delay URLContext allocation until parse finishes
and skip ToString when the input is already a string.

Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Assisted-by: Cursor
PR-URL: https://github.com/nodejs/node/pull/65361
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daniel Lemire <daniel@lemire.me>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-08-23 03:31:17 +00:00
Taejin Kim 2df4ce7c5c lib: use bracket notation instead of startsWith/endsWith for single char
Signed-off-by: Taejin Kim <rlaxowls1316@naver.com>
PR-URL: https://github.com/nodejs/node/pull/61500
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-23 02:39:25 +00:00
armanmikoyan 97c7e327f1 dgram: don't swallow bind errors when callback is provided
Signed-off-by: armanmikoyan <arman.mikoyan1@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62602
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-08-23 02:39:15 +00:00
trivenay da7b94e0ae quic: reset rejected HTTP/3 request streams with H3_REQUEST_REJECTED
An incoming HTTP/3 request stream rejected without any application
processing (the session has no stream consumer) is now reset with
H3_REQUEST_REJECTED so the peer learns the request was not processed,
per RFC 9114 section 4.1.1. The code is surfaced per-application like
the existing no-error and internal-error codes, so non-HTTP/3
applications are unchanged.

Fixes: https://github.com/nodejs/node/issues/65441
Signed-off-by: Naman Trivedi <trivenay@amazon.com>
PR-URL: https://github.com/nodejs/node/pull/65442
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-23 02:38:57 +00:00
Matteo Collina 82babee3e6 stream: avoid duplicated endReadableNT scheduling
Calling read() on an ended stream multiple times before the microtask
queue drains scheduled one endReadableNT tick per call, as the only
guard was endEmitted, which is set inside the tick itself. A hello-world
HTTP server was scheduling it four times per request while dumping the
unread request body.

Introduce a kEndScheduled flag armed when the tick is scheduled and
cleared when it runs. Clearing it unconditionally matters for reused
sockets: undestroy() resets endEmitted through the state descriptors
but cannot reach this flag, and a stale value would block the 'end'
event after a net.Socket reconnect.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65310
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-08-23 01:23:36 +00:00
Sumit Kumar Das 3ff8c2dbde esm: avoid super-linear data URL MIME regex
The MIME regex used for data: URLs could backtrack super-linearly on a
malformed URL lacking a ',' separator. Make the optional parameter
group anchored on ';' so it cannot overlap with the media-type group.

Adds a benchmark (esm/get-data-protocol-format) parameterized over
path length, so a backtracking regression shows up as an ops/sec
cliff instead of a wall-clock assertion in a test, per review.

Fixes: https://github.com/nodejs/node/issues/61904
Signed-off-by: skdas20 <skdas5405@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/61951
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-22 20:37:46 +00:00
mag123c 2858f34652 test_runner: print coverage and diagnostic info with dot reporter
When using the dot reporter with coverage enabled, coverage threshold
failures and coverage reports were not printed, only an exit code was
returned. This made it impossible to know why the test run failed.

This change adds handling for test:diagnostic and test:coverage events
to the dot reporter, matching the behavior of the spec reporter.

Fixes: https://github.com/nodejs/node/issues/60884
Signed-off-by: mag123c <diehreo@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/61423
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-22 12:09:19 -07:00
Yagiz Nizipli 4b3bba58dd url: speed up URLSearchParams
Parse query strings with indexOf instead of a per-character state
machine, skip ToString when values are already strings, cache
toString() until the list mutates, and join serialized pairs.

Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Assisted-by: Cursor
PR-URL: https://github.com/nodejs/node/pull/65363
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-22 18:48:28 +00:00
Jerry Zhao 7d69ed11f7 fs: pass symlink type in cp when filter is provided
When `fs.cp`/`fs.cpSync` is called with both `verbatimSymlinks: true`
and a `filter` function, directory symlinks were incorrectly created
as file symlinks on Windows.

Without a `filter`, cp takes the C++ fast path (`cpSyncCopyDir`) which
uses `std::filesystem::copy_symlink()` and preserves the symlink type
automatically. With a `filter`, the JS fallback calls `symlinkSync`/
`symlink` without a `type` argument. On Windows, that causes the type
to be auto-detected by stat-ing the resolved target at the destination,
but during a recursive copy the target directory may not exist yet at
the destination (e.g. `linked/` is copied before `packages/` in
alphabetical order). The stat fails and `type` falls back to `'file'`,
producing a file symlink in place of a directory symlink.

Detect the symlink type from the source (which always exists) via
`internalModuleStat(src)` and pass it explicitly to the `symlinkSync`/
`symlink` call sites. `onLink` already computed `srcIsDir` for
subdirectory validation; hoist that computation above the early-return
paths and thread the derived `symlinkType` through `copyLink` as well.
Both the sync (`cp-sync.js`) and async (`cp.js`) implementations are
fixed.

Add two regression tests that copy a tree containing a relative
directory symlink with `verbatimSymlinks: true` and a `filter`
function, then assert the destination link still resolves as a
directory.

Fixes: https://github.com/nodejs/node/issues/62653
Signed-off-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/62654
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-08-22 17:44:37 +00:00
Shelley Vohr e38eede0e5 lib: load fewer builtins when bootstrapping without a snapshot
Contexts that are not deserialized from the built-in snapshot -- worker
threads, and the main context of embedders that create their own
isolate or of `node --no-node-snapshot` -- compile (with the code cache
at best) every builtin the bootstrap touches, so each eagerly required
builtin is startup time (~0.15-0.4 ms apiece). A number of them are only
required eagerly so that they end up in the snapshot, or for features
the bootstrap path never uses.

Load lazily what those paths do not need:

- is_main_thread.js: preload util, url, the ESM loader (translators,
  resolver, module_job/map, source maps, node:module, vm modules, mime,
  data_url, the TypeScript stripper), internal/blob and
  internal/dns/utils only while building a snapshot; they load on first
  use otherwise.
- fs: internal/blob (+ internal/encoding and its tables) is only used
  by fs.openAsBlob().
- internal/url: internal/data_url (+ internal/mime) is only used by the
  Buffer-returning file URL helpers.
- internal/process/execution, the CommonJS loader, esm/translators and
  esm/load: the TypeScript stripper and data: URL helpers are only
  needed for TypeScript sources / data: URLs.
- pre_execution: internal/dns/utils (+ internal/net) is only needed up
  front to validate an explicit --dns-result-order or to register the
  resolver's snapshot serializer; the default order becomes the
  variable's initializer.
- internal/worker: event_loop_utilization and error_serdes are only
  needed once a sub-worker's ELU is read or it reports an error.
- worker_threads: `locks` is defined lazily, like util's lazy exports.

Main-thread startup with the snapshot is unchanged (the same modules
are preloaded into it; the bootstrap-modules test lists are adjusted).
A bare worker compiles 95 -> 83 builtins (cold start -5%); without the
snapshot an empty CommonJS entry point compiles 76 -> 59 builtins and an
empty ES module entry point 76 -> 69.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65329
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-22 17:07:39 +00:00
Trivikram Kamat bd25af32cc ffi: prefer canonical type names
Document long type names as canonical and use them in examples.
Group alternative spellings separately in the documentation and
internal type maps while retaining support for every existing alias.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/65417
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-08-22 07:28:28 +00:00
Richard Gibson a48e33fb6f util: fix formatting of functions returned from getters
Fixes: https://github.com/nodejs/node/issues/64838
Signed-off-by: Richard Gibson <richard.gibson@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64839
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-22 05:07:59 +00:00
Shivay-98 6586288a41 net: handle undefined parent in _unrefTimer and _destroy
The fix and approach are from #64491 by Shivay-98; this reopens it to
get it landed, since the original stalled awaiting requested changes.

`Socket.prototype._unrefTimer` and `Socket.prototype._destroy` both walk
the `_parent` chain with a strict `!== null` check. During connection
teardown a socket's `_parent` can be left `undefined` (for example a TLS
socket layered over another stream), so the loop steps onto `undefined`
and reads a property off it, throwing a TypeError:

    Cannot read properties of undefined (reading 'Symbol(timeout)')

from an uncaught I/O callback and crashing the process.

Using a nullish (`!= null`) check terminates the walk on both `null` and
`undefined`.

[petter@hightouch.io: apply the same fix to the identical loop in
`_destroy`, which the original regression test already exercised via
`destroy()`; add direct unit coverage for both paths.]

Fixes: https://github.com/nodejs/node/issues/64490
Refs: https://github.com/nodejs/node/pull/64491

Signed-off-by: Petter Häggholm <petter@hightouch.io>
PR-URL: https://github.com/nodejs/node/pull/64644
Fixes: https://github.com/nodejs/node/issues/64490
Refs: https://github.com/nodejs/node/pull/64491
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-08-21 19:33:38 -07:00
Sylvester Keil 34db39b963 test_runner: use run options with isolation="none"
When using run() programatically with isolation="none",
testNamePatterns, testSkipPattersn, and only were ignored.
This combination of options only worked when set via CLI flags,
because parseCommandLine() is still used to seed globalOptions.

Fixes: https://github.com/nodejs/node/issues/57399
Signed-off-by: Sylvester Keil <sylvester@keil.or.at>
PR-URL: https://github.com/nodejs/node/pull/62269
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
2026-08-21 18:47:46 -07:00
Maruthan G 9d94b6548a test_runner: mock dual-package with conditional exports
When `mock.module()` targets a package whose `exports` field maps
`import` and `require` to different files, the ESM resolver and the
CJS resolver disagree on the resolved path. Only the ESM path was
registered in `mockMap`, so `require()` of the mocked specifier
bypassed the mock and loaded the real CJS module.

Resolve the specifier through `Module._resolveFilename` from the
caller's directory in addition to the existing ESM resolution. When
the two paths differ, register the CJS path as a second key in
`mockMap` and invalidate `Module._cache[cjsPath]`, restoring it on
`restore()`. Single-resolution packages keep their existing behavior.

Fixes: https://github.com/nodejs/node/issues/58231
Signed-off-by: Maruthan G <maruthang4@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62943
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Jacob Smith <jacob@frende.me>
2026-08-21 13:09:19 -07:00
Paul Bouchon 838a3e9051 test_runner: restore directory search for --test
Passing a directory to `node --test` (e.g. `node --test tests`) matched
the directory itself as a glob pattern and then tried to run it as a
test file, failing with MODULE_NOT_FOUND. Before glob patterns were
supported, a directory argument was searched for test files within it.

Expand a pattern that resolves to a directory into a search for the
default test files inside it. Despite the report framing this as
Windows-only, it reproduces on every platform: it is a plain
regression from when directory arguments stopped being searched.

Fixes: https://github.com/nodejs/node/issues/64555
Signed-off-by: Paul Bouchon <mail@bitpshr.net>
PR-URL: https://github.com/nodejs/node/pull/64637
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-08-21 13:03:46 -07:00
Lazizbek Ergashev da2d6178a6 dns: validate address type in lookupService
Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64878
Fixes: https://github.com/nodejs/node/issues/64877
Reviewed-By: theanarkh <theratliter@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-08-21 00:50:05 +00:00
June b5d37cd41e lib: fix ERR_INVALID_ARG_TYPE with --enable-source-maps
Signed-off-by: June Kim <kimjune01@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63215
Fixes: https://github.com/nodejs/node/issues/63169
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-08-20 23:02:33 +00:00
mag123c e2cb91d08a test_runner: add classname hierarchy for JUnit reporter
Signed-off-by: mag123c <diehreo@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/60220
Fixes: https://github.com/nodejs/node/issues/59417
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-20 19:16:07 +00:00
trivenay fd5b13557f quic: do not destroy incoming streams that have a consumer
An incoming stream was destroyed unless the session had an onstream
callback, even when session-level stream callbacks (onheaders et al)
were registered and the negotiated application (HTTP/3) would drive
the stream through them. Users had to register stub onstream handlers
just to keep their streams alive.

Destroy an incoming stream only when the session has no consumer for
it at all: no onstream callback, and no session-level stream callbacks
runnable on the negotiated application (checked via the existing
headersSupported session state, computed when the application is
selected from ALPN). Sessions with no consumers keep the current
destroy-and-warn behavior so unconsumed streams cannot accumulate and
hold flow control credit.

On HTTP/3 sessions only bidirectional request streams reach this path;
control and QPACK streams are consumed internally by nghttp3 and are
never exposed to JavaScript.

Fixes: https://github.com/nodejs/node/issues/64192

Signed-off-by: Naman Trivedi <trivenay@amazon.com>
PR-URL: https://github.com/nodejs/node/pull/65335
Fixes: https://github.com/nodejs/node/issues/64192
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-08-20 07:03:21 +00:00
Matteo Collina 28995396b2 stream: decouple transform backpressure changes
The spec's [[backpressureChangePromise]] is only ever observed by the
transform source pull algorithm (settles when backpressure next becomes
true) and by a sink write arriving under backpressure (settles when it
next becomes false), both internal. Replace the promise record with
direct continuation delivery: a parked pull is completed by enqueueing
the readable controller's pull-fulfilled step on the shared resolved
promise, and a parked write by a cached per-stream continuation that
resolves the sink promise with the perform-transform promise, so
adoption reproduces the previous derived-chain settle depth exactly.
Each delivery lands at the same microtask position as the old record's
reaction.

transformStreamDefaultControllerPerformTransform now mirrors the
reference implementation's promiseCall().then(undefined, rejection
steps) directly instead of running an async wrapper pair per chunk: the
transformer.transform callback is wrapped raw, a non-thenable result
reuses the shared resolved promise, and a synchronous throw is
delivered through a rejected promise, keeping the error timing inside a
reaction.

A pipe-through benchmark is added since the suite had no
transform-throughput row.

pipeThrough passthrough improves by ~8% and a writer-driven transform
loop by ~14%; the pipe-to and read families are unchanged.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65143
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-08-20 03:56:00 +00:00