Commit Graph
13372 Commits
Author SHA1 Message Date
Marten Richter 3521a6e311 quic: add option waitUntilAvailable to creating streams
We add an option to createBidirectionalStream and
createUnidirectionalStream to fail immediately,
if the flow control's stream budget does not
allow stream creation.
The behavior matches W3C webtransport's behavior.

Fixes #65321

Signed-off-by: Marten Richter <marten.richter@freenet.de>
PR-URL: https://github.com/nodejs/node/pull/65331
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-19 19:14:32 +00:00
Tim Perry eda8de765b http2: don't fail response reads after clean RST_STREAM
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67558
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-19 19:14:15 +00:00
Vlad Frangu 42800b60d3 os: expose guessFileDescriptorType
Exposes the internal `guessHandleType` function as
`guessFileDescriptorType`, which can be used to see if a handle has a
specific type, regardless of the OS it is on.

This helps out with detecting, for example, if standard input is piped
into the process, instead of relying on file system calls.

Refs: https://github.com/nodejs/node/issues/57603
Signed-off-by: Vlad Frangu <me@vladfrangu.dev>
PR-URL: https://github.com/nodejs/node/pull/58060
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-11-19 10:46:13 -07:00
Tim Perry db671bb416 http2: fix eos() for HTTP/2 streams after clean end & close
Previously this could fail - not having read 'end' when the close
arrived was treated as a premature close error for finished() and
related APIs, even though the body data was cleanly ended and complete.
We now check whether there is a clean end buffered. If so, we wait
until it's read before evaluating whether the stream ended cleanly.

Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67553
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-19 17:41:27 +00:00
Matteo Collina f4fab9770b module: avoid dictionary-mode objects on hot paths
V8 keeps objects created from `{ __proto__: null }` literals, and from
v8::Object::New() with names and values, in dictionary mode for their
whole life. The module loader created such objects on every require()
of a builtin and every import(), and kEmptyObject, the cached ESM
resolve results and the requests from getModuleRequests() were all
in dictionary mode as well.

Use classes with a null-prototype prototype for the per-call objects,
null the prototype of plain literals for the long-lived ones, and
build module requests from a DictionaryTemplate.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67552
Refs: https://adventures.nodeland.dev/archive/optimizing-objects-with-null-prototypes/
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-19 17:31:56 +00:00
Gürgün Dayıoğlu 41918c1d44 buffer: use typed arrays for 64-bit BigInt accessors
readBig(U)Int64{LE,BE}() and writeBig(U)Int64{LE,BE}() assembled and
split values with BigInt arithmetic, allocating intermediate BigInts on
every call. Copy the bytes through BigInt64Array and BigUint64Array
views over the existing 8-byte scratch buffer instead, as the double
accessors already do.

Range and bounds checks are unchanged, and the value is masked with
`& -1n` before the store so non-BigInt values still throw the same
TypeError instead of being coerced by the typed array.

benchmark/buffers/buffer-read.js now uses the value it reads. The
loop discarded it, which let V8 remove side-effect-free reads
altogether.

Assisted-by: claude:opus-5.5
Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
PR-URL: https://github.com/nodejs/node/pull/67549
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-19 17:13:01 +00:00
Ethan Arrowood 86b9e3544c http,http2: copy header arrays in setHeader
setHeader() stored the caller's array and that led to mutation
issues with appendHeader() pushing new values into it. The caller
would see values added to that array, and if the array was frozen
appendHeader() would throw a TypeError.

This fix copies the array value instead so the response instance
owns it completely. getHeader() still return the stored array.

It also applies the same change to HTTP2 compat api.

Fixes: https://github.com/nodejs/node/issues/67526
Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ethan Arrowood <ethan@arrowood.dev>
PR-URL: https://github.com/nodejs/node/pull/67528
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-19 16:50:31 +00:00
Yuya Inoue f442b5a232 http2: add callback to informational header methods
In the HTTP/1 server, writeContinue(), writeEarlyHints() and
writeInformation() accept a callback that is called once the response
has been written to the socket. The HTTP/2 compat versions did not, so
code moving to the compat API had its callback ignored.

Accept an optional callback in http2stream.additionalHeaders() and in
the three compat methods. The request for the HEADERS frame is tracked
until nghttp2 serializes the frame, and completed together with the
write to the underlying stream that carries it.

Signed-off-by: inoway46 <inoueyuya416@gmail.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/67470
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-19 16:39:21 +00:00
Jacky Zhao 0c8797b2a6 module: don't map a trailing generated-only segment
The mappings parser detects a segment that has only a generated column
by peeking at the next character. At the end of the mappings string the
peek returns an empty string, which is not a separator, so a final
generated-only segment is decoded with phantom zero deltas and inherits
the source, line, and column of the segment before it. With
--enable-source-maps, stack frames in code after the last mapped
segment are then attributed to the last mapped source.

Check for the end of the string before reading source fields.

Signed-off-by: Jacky Zhao <j.zhao2k19@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66264
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-19 15:50:19 +00:00
René c91d8aa1a5 fs: use try...finally for abort race
Signed-off-by: Renegade334 <rene@renegade334.me.uk>
PR-URL: https://github.com/nodejs/node/pull/67545
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-19 14:57:12 +00:00
Robert Nagy 029acbfbd7 lib: stop refreshing composite AbortSignals
AbortSignal.any() follows its sources as soon as it creates a
composite, so aborting a source synchronously aborts every composite
that follows it. The aborted and reason getters and throwIfAborted()
still walked the composite's sources on every call and dereferenced
the WeakRef of each one, which is expensive because
WeakRef.prototype.deref() adds its target to the kept objects of the
current job.

That walk can no longer find an aborted source of a composite that
isn't aborted itself, so remove it. throwIfAborted() on a composite
with two sources becomes about 17 times faster, the same as on a
plain signal.

Add a benchmark for throwIfAborted() on plain, timeout, composite and
mixed signals.

Assisted-by: claude:opus-5.5
Signed-off-by: Robert Nagy <ronagy@icloud.com>
PR-URL: https://github.com/nodejs/node/pull/67543
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-19 14:16:59 +00:00
Trivikram Kamat d9e18d51d5 vfs: normalize RealFSProvider mkdir return paths
RealFSProvider.mkdirSync()/mkdir() forwarded the raw fs.mkdirSync()
result, which for { recursive: true } is the absolute backing-directory
path of the first created directory. VirtualFileSystem#toMountedPath()
then joined the mount point with it, producing <mount>/<root>/a instead
of <mount>/a, so the returned path failed fs.existsSync().

Reuse the existing #resolvedToVfsPath() helper (as realpath does) to
translate the result back to a provider-relative VFS path, matching
MemoryProvider.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: opencode
PR-URL: https://github.com/nodejs/node/pull/66221
Fixes: https://github.com/nodejs/node/issues/66220
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-19 08:20:45 +00:00
Matteo Collina c47b8d8781 url: restrict option copying in urlToHttpOptions to URL instances
Only spread own enumerable properties for URL instances created by this
realm's URL constructor. Duck-typed objects accepted by isURL() can no
longer smuggle connection options (socketPath, method, headers, agent)
into a request.

This fixes a footgun where a hostname-validated http.request() could be
redirected to a Unix socket (e.g. the Docker daemon) via a URL-shaped
object, bypassing hostname-based SSRF checks. Extending a genuine URL
object with extra options is preserved.

Refs: https://github.com/nodejs/node/pull/46989
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67454
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-11-19 08:20:21 +00:00
Ved Chaudhari cdd06876da fs: restore stack traces of fs/promises stat permission errors
Since stat() started going through raceWithSignal(), permission
errors from fsPromises.stat() have had no stack frames. The binding
rejects them right away, and raceWithSignal() returned that promise
from an async function without awaiting it, so nothing was awaiting
it yet when the stack was captured.

Return the promise as is when there is no signal, so stat() awaits
it directly again.

Refs: https://github.com/nodejs/node/pull/63143
Signed-off-by: vedchaudhari <vedc2853@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67525
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
2026-11-19 03:40:55 +00:00
inoway46 371ac095ac tls: destroy sockets after fatal errors
Destroy established TLS sockets on fatal errors so pending writes
cannot prevent HTTP/2 session cleanup from completing. Defer closing
until after error handling to preserve connection details for listeners.

Add regression coverage for standalone TLS socket closure and HTTP/2
cleanup with default and custom TLS connections.

Fixes: https://github.com/nodejs/node/issues/67213
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/67215
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-19 02:21:25 +00:00
inoway46 3f61461631 net: clear closed handles before emitting close
Clear a deferred socket handle before invoking close listeners. TLS has
already freed its SSL state at this point, so retaining the handle lets
getProtocol() access a null SSL pointer and crash the process.

Keep connection details available during tlsClientError and add coverage
for querying the protocol after a failed handshake closes the socket.

Signed-off-by: inoway46 <inoueyuya416@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/67215
Fixes: https://github.com/nodejs/node/issues/67213
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-19 02:21:24 +00:00
Tim Perry b7df44bf9c tls: docs-deprecate TLS renegotiation, add allowRenegotiation opt-in
For now this changes very little, but offers an option to directly
control whether this is supported. In future, this will default to
'false' (disabling by default) and eventually be mostly removed,
except opt-in client support for accepting renegotiation requests
from servers.

Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67532
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-18 22:39:56 +00:00
Ethan Arrowood 0f2c06155d tools: apply http lint rule to lib/internal/http
The `lib/_http_*.js` files moved to `lib/internal/http/` recently.
But the ESLint config still only listed the old paths. The moved
files lost the "Do not use prototype primordials in this file"
check that other HTTP hot paths have.

This change adds `lib/internal/http/*.js` to that rule list. The
files already comply so no other changes are needed.

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ethan Arrowood <ethan@arrowood.dev>
PR-URL: https://github.com/nodejs/node/pull/67529
Refs: https://github.com/nodejs/node/pull/58535
Reviewed-By: Efe Karasakal <hi@efe.dev>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-11-18 20:00:13 +00:00
Lazizbek Ergashev 5a823400b2 lib: end --eval crypto wrapper code with a newline
Assisted-by: Claude Code
Signed-off-by: lazerg <lazerg2@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67162
Fixes: https://github.com/nodejs/node/issues/67159
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-11-18 17:55:41 +00:00
James M Snell d77ed7854e fs: move DEP0187 to End-of-Life
Passing an invalid argument type to fs.existsSync() now throws
ERR_INVALID_ARG_TYPE instead of returning false. Other invalid paths,
such as strings containing null bytes or non-file: URLs, continue to
return false.

This has been a runtime deprecation since v24.0.0.

Refs: https://github.com/nodejs/node/pull/55753
Refs: https://github.com/nodejs/node/pull/55892
Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67494
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-11-18 12:02:29 +00:00
Moshe Atlow 20a93ab52b test_runner: scope rerun ids to the entry file
With process isolation, the `--test-rerun-failures` state file is
written by the parent process, which numbered tests sharing a location
across all test files, while each child process numbers them within
its own file. A test defined in a helper used by several test files
was therefore looked up in a slot belonging to another file, and a
failing test could be replayed as passed without running.

Prefix the identifier of a test defined outside of its entry file with
the entry file when tests run in per-file child processes, and build
the identifier with the same helper on both sides.

Signed-off-by: Moshe Atlow <moshe@atlow.co.il>
PR-URL: https://github.com/nodejs/node/pull/67512
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2026-11-18 09:39:47 +00:00
Moshe Atlow 19cb394896 test_runner: resolve entryFile against the cwd option
The location of a test file run in a child process was resolved
against `process.cwd()`, so `run()` reported a wrong `entryFile` for
relative paths when called with a different `cwd`.

Signed-off-by: Moshe Atlow <moshe@atlow.co.il>
PR-URL: https://github.com/nodejs/node/pull/67512
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2026-11-18 09:39:46 +00:00
Gürgün Dayıoğlu 369b9c88ac http: keep request option copies in fast mode
The options of every client request are copied several times: once
in ClientRequest to merge the URL and the options, once more to
build the options handed to the agent, and again in Agent#addRequest
(on every request, including keep-alive reuse) and createSocket to
merge in the agent options. Each copy was a `{ __proto__: null, ...}`
literal or an Object.assign() onto `{ __proto__: null }`. V8 creates
such an object in dictionary mode, and copying from a dictionary-mode
source takes the generic slow path, so every copy in the chain was
slow and fed a slow source into the next one.

Use kEmptyObject, a frozen object with a null prototype and no
properties, as the prototype of each copy instead of null. The copy
still inherits nothing, has the same own properties in the same
order, and stays in fast mode. The same is done for the copy of the
options in the http and https Agent constructors, which is the
source of the agent options merged into every request.

benchmark/http/create-clientrequest.js improves by 2 to 24 % at the
default e=1 (50 runs) and by 49 to 87 % with e=6 (30 runs).

Assisted-by: claude:opus-5.5
Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
PR-URL: https://github.com/nodejs/node/pull/67395
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-11-18 08:51:01 +00:00
Efe Karasakal 3e797cbda2 quic: handle application-specific no-error codes
Signed-off-by: Efe Karasakal <hi@efe.dev>
PR-URL: https://github.com/nodejs/node/pull/67094
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-18 07:50:23 +00:00
Matteo Collina 93053532e8 stream: keep async context of the pipeTo pump
The pipeTo() pump re-enters from the destination's ready hook, which
writableStreamUpdateBackpressure invokes synchronously, and from the
chunk steps of its read request. Both run in the async context of the
code that cleared the backpressure or enqueued the chunk, so the
source's pull() and the writes issued after a resumption observed that
context instead of the one of the pipeTo() call, as they did with the
promise-based pump. Capture the async context frame when the pipe starts
and run the pump in it.

Refs: https://github.com/nodejs/node/issues/66906
Refs: https://github.com/nodejs/node/pull/65138
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67054
Refs: https://github.com/nodejs/node/pull/67052
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-11-18 06:45:33 +00:00
Yohannes Desta 1fb0cd6978 fs: validate opendir() bufferSize before opening the directory
fs.opendir() only checked options.bufferSize in the Dir constructor,
which runs from the completion callback of the native opendir call.
An invalid value was thrown from there, so it could not be caught and
the process exited. fs.promises.opendir() is built on fs.opendir() and
had the same problem.

Check bufferSize before starting the native call, so fs.opendir()
throws to the caller and fs.promises.opendir() rejects.

Fixes: https://github.com/nodejs/node/issues/67182
Signed-off-by: Yohannes Desta <yohannesdestagebru10@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67183
Reviewed-By: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
2026-11-18 03:59:25 +00:00
Bryan English 7fa06d4717 http2: allow client request header injection via diagnostics_channel
The http2.client.stream.created and http2.client.stream.start channels
publish the stream's sentHeaders object, but by that point the request
headers have already been serialized in ClientHttp2Session#request().
Mutating the published object has no effect on the wire, so tracing
instrumentation has no way to add context headers such as traceparent to
outgoing HTTP/2 client requests.

Add a new http2.client.request.headers channel, published when
ClientHttp2Session#request() is called, before the headers are validated
and serialized. Subscribers receive a shallow copy of the headers object
passed by the caller and can mutate it in place to add or modify request
headers. When request() is called without headers, a fresh object is
published so subscribers can still inject headers. The caller's own
headers object and its sensitiveHeaders list are never modified, so
header objects can be safely reused or forwarded across requests.
Injected headers go through the same validation as headers passed
directly to request().

The existing created and start channels are unchanged.

Assisted-by: pi
Signed-off-by: Bryan English <bryan@bryanenglish.com>
PR-URL: https://github.com/nodejs/node/pull/67069
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-17 20:38:06 +00:00
James M Snell 3193305572 stream: deduplicate string chunk encoding in web stream adapters
The Writable and Duplex adapters created from web streams duplicated
the logic that encodes string chunks as a Uint8Array before writing
them to the WritableStream. Move it into a shared encodeStringChunk()
helper.

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67495
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-11-17 18:37:05 +00:00
James M Snell 67798df884 util: share helpers between debounce() and throttle()
util.debounce() and util.throttle() duplicated the construction of the
AbortError used for cancel()/abort, and the property definitions for
the returned function's control methods, state getters, length, and
name. Move both into internal/util/wrapped_function.

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67495
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-11-17 18:37:00 +00:00
James M Snell 8002dbdc27 http: share insecureHTTPParser/httpValidation option handling
ClientRequest and Server duplicated the validation of the
insecureHTTPParser and httpValidation options, including the check
that they are mutually exclusive. Move it into a shared
setHttpParserOptions() helper in internal/http.

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67495
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-11-17 18:36:56 +00:00
James M Snell c807380348 crypto: deduplicate WebCrypto SPKI/PKCS#8 exporter lookup
exportKeySpki() and exportKeyPkcs8() contained identical switch
statements mapping the algorithm name to its export function. Move
the lookup into a shared getAsymmetricKeyExporter() helper.

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67495
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-11-17 18:36:52 +00:00
James M Snell fd6ba3f246 crypto: share asymmetric WebCrypto key import logic
The RSA, EC, CFRG, ML-DSA, and ML-KEM importKey implementations each
duplicated the handling of the 'KeyObjectHandle', 'spki', and 'pkcs8'
formats. Move it into a shared importAsymmetricKeyHandle() helper in
webcrypto_util, with an optional hook that ML-DSA and ML-KEM use to
reject PKCS#8 keys without a seed.

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67495
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-11-17 18:36:47 +00:00
James M Snell 1727b138f9 esm: move DEP0155 and DEP0166 to End-of-Life
Package "exports" subpaths ending in "/" now throw
ERR_INVALID_MODULE_SPECIFIER instead of emitting DEP0155, matching
the existing "imports" behavior and the documented resolution
algorithm.

"imports" and "exports" targets containing empty segments (double,
leading, or trailing slashes after the initial "./") now throw
ERR_INVALID_PACKAGE_TARGET, and pattern matches containing empty
segments now throw ERR_INVALID_MODULE_SPECIFIER, instead of emitting
DEP0166.

The isPathMap parameter, which only served to suppress DEP0166 for
trailing slash pattern resolutions, is removed.

DEP0155 has been a runtime deprecation since v17.0.0, DEP0166 since
v19.0.0.

Refs: https://github.com/nodejs/node/pull/40117
Refs: https://github.com/nodejs/node/pull/44495
Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67488
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-17 16:41:10 +00:00
James M Snell 6c835918fb crypto: move DEP0179 and DEP0181 to End-of-Life
Calling the Hash or Hmac constructors directly, with or without new,
now throws ERR_ILLEGAL_CONSTRUCTOR. Instances must be created with
crypto.createHash() and crypto.createHmac().

The classes remain exported from node:crypto so that instanceof checks
continue to work. Internally, instances are constructed through a
private symbol, and the createHash() and createHmac() factories now
live alongside the classes in internal/crypto/hash.

Both have been runtime deprecations since v22.0.0.

Refs: https://github.com/nodejs/node/pull/51880
Refs: https://github.com/nodejs/node/pull/52071
Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67490
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-17 16:40:55 +00:00
Jacky Zhao 3db9632585 module: store source map mappings in a typed array
SourceMap kept one six-element array per mapping segment. Bundled
applications have millions of segments, and with --enable-source-maps
a parsed map lives for the life of the process: a 63 MB source map with
2.9 million segments retained about 290 MiB of heap.

Store the segments in a single Int32Array, six fields per segment, and
resolve source URLs and names through per-map tables. Segments are
counted before parsing so storage is allocated once, and sorting is
skipped when the mappings are already in order. The public API and the
objects returned by findEntry() and findOrigin() are unchanged.

Signed-off-by: Jacky Zhao <j.zhao2k19@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66261
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-17 14:58:30 +00:00
Gabe De Mesa cdc1dacdd5 http2: enforce maxSessionMemory for client requests
The documentation for `maxSessionMemory` says new streams are rejected
while the limit is exceeded. That was only enforced for streams opened
by the peer (`Http2Session::CanAddStream()`). `session.request()` went
straight to `nghttp2_submit_request()`, so a client whose socket
stopped draining could keep queuing requests in nghttp2 without bound.

Check the session memory before submitting a request. If it is over
the limit, reject only that request with the new
`ERR_HTTP2_SESSION_MEMORY_EXCEEDED` error. Nothing is sent to the peer,
so the request can be retried, and the session stays usable. As with
response headers, request bodies queued for flow control are not
counted, so large uploads do not block unrelated requests on the same
session.

Refs: https://github.com/nodejs/undici/issues/6181
Assisted-by: a closed-source coding agent
Signed-off-by: Gabe De Mesa <gdemesa@opengov.com>
PR-URL: https://github.com/nodejs/node/pull/67361
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-17 13:26:40 +00:00
Ved Chaudhari d2da05f14b util: fix debounce/throttle abort listener leak
debounce() and throttle() added an abort listener to the signal when
they were created and never removed it, so a long-lived signal kept
every debounced or throttled function, and its data, in memory.

Only listen for abort while calls are pending. Calls made after the
signal is aborted still reject, since each call checks signal.aborted.

Assisted-by: a closed-source coding agent
Signed-off-by: vedchaudhari <vedc2853@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66839
Refs: https://github.com/nodejs/node/pull/65899
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2026-11-17 11:47:28 +00:00
Joyee Cheung 1c40cface6 inspector: support attaching to a running process in probe mode
Probe mode currently only launches a new process from the entry point
script. This change lets it attach to an already-running process, so a
long-lived application can be inspected without restarting it.

Running `node inspect --probe` without specifying an entry point script
instructs Node.js to attach to a running Node.js process and probe.
The way attaching is done is specified through command line arguments:

- `--pid <pid>` activates the target's inspector (if it's not already
  activated) and connects to it.
- `--host <host>` and `--port <port>` specify an address where an
  inspector is listening. The host defaults to 127.0.0.1 and the
  port defaults to 9229.

When the session ends, probe mode resumes and detaches instead of
killing a process it does not own. The report now includes a top-level
`target` field describing what was probed, and each probe contains a
`locations` field about where it bound.

An attach session ends when a probe reaches `--max-hit`
(reported as `completed`), when the target finishes on its
own (`completed`, or `miss` with the pending probes, and the target is
then allowed to exit), or when `--timeout` fires (reported as
`timeout`, the probing process exit with 0 and reports the hits recorded
so far).

`--timeout` now is also applied to the startup phase in both modes, so
a target that never responds before the breakpoints are bound is
reported as an error instead of hanging.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67201
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-17 09:51:42 +00:00
emyeiandTim Perry bf07beacf3 http: forward-port the pending-read fix for CVE-2026-105481
The Agent data guard only runs once the event loop polls for I/O. Data
that reaches an idle kept-alive socket's OS buffer right before that
poll can be handed to the next request as if it were that request's
own response (response-queue poisoning).

Commit 0683ee5f ("http: ensure agent data guard works without I/O",
CVE-2026-105481) fixed this by checking the OS directly via a new
LibuvStreamWrap::HasPendingRead before reusing a free socket. It
landed in lib/_http_agent.js on the release branches (shipped in
v26.12.1) but was never forward-ported after PR #58535 moved the Agent
implementation to lib/internal/http/agent.js on main five days
earlier. As a result, main (and any v27 nightly built from it) lost
the protection even though every supported release line (22.x/24.x/
26.x) still has it.

This restores the complete fix on main:
- lib/internal/http/agent.js: re-add the hasPendingRead() helper and
  its two call sites (the free socket handed to a queued request, and
  the free-pool socket selected in addRequest), ported 1:1 to the
  current structure of the file.
- lib/internal/tls/wrap.js, src/stream_wrap.cc/.h: unchanged from the
  original fix, which already applies cleanly on main.
- test/parallel/test-http-agent-free-socket-pending-read.js: restore
  the regression test covering both assignment paths, so the fix
  cannot be silently dropped again by a future refactor.

Fixes: https://hackerone.com/reports/4038361
CVE-ID: CVE-2026-105481

Co-authored-by: Tim Perry <pimterry@gmail.com>
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67073
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-17 09:18:07 +00:00
Matteo Collina cb4cba6d0b http2: do not end compat requests reset before END_STREAM
When the peer reset a stream before sending END_STREAM, the compat
`Http2ServerRequest` still pushed EOF from its 'close' handler, so it
emitted 'end' for a truncated body (on main even after 'error' and
'close'). Unlike http1, where an aborted `IncomingMessage` is destroyed
and never emits 'end', applications listening for 'end' then processed
the partial body as if it were complete.

Record in `onStreamClose()` that the peer closed the stream before
END_STREAM, since `destroy()` ends the readable side afterwards, and
destroy the request instead of ending it in that case. Requests whose
body was complete before the reset still end normally.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67061
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-16 21:47:08 +00:00
Matteo Collina d5af389400 stream: use distinct webstreams brand checks
The brand checks were closures returned by one isBrandCheck() factory.
Closures of the same function literal share their feedback vector, so
the kState and kType loads in every check saw all the stream classes
and went megamorphic. Declare each check as its own function.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67433
Reviewed-By: Mattias Buelens <mattias@buelens.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-11-16 20:37:16 +00:00
Marten Richter 0dd11e5f11 quic: create gen. getWriter for stream/iter
The get writer method of QuicStream is mostly
generell enough to be usuable in other contexts.
This PR is an attempt to move the code out
of the QuicStream object to be usuable in other
parts of node.js.

Fixes #66508

Signed-off-by: Marten Richter <marten.richter@freenet.de>
PR-URL: https://github.com/nodejs/node/pull/66513
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-16 20:27:32 +00:00
Filip Skokan 95b3edd529 crypto: make backend requirements explicit
Name OpenSSL and BoringSSL alternatives and add errors for unsupported
backends. This helps catch incomplete backports.

Remove redundant feature aliases and check APIs and constants to detect
capabilities. Retain version checks for behavioral differences.

Determine Argon2 support through provider fetches. Register Argon2Job
based on API availability, including builds configured without Argon2.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/67472
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-11-16 20:01:15 +00:00
Aliaksandranddevholic22 d3c4048962 test_runner: remove failure attribute from JUnit reporter
This commit aligns the Node.js test runner's JUnit XML output with the
official JUnit specification by removing the non-standard failure
attribute from elements.

Signed-off-by: Aliaksandr <42497203+AlexCannonball@users.noreply.github.com>
Co-authored-by: devholic22 <hyunjoon.tech@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66072
Fixes: https://github.com/nodejs/node/issues/59593
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-11-16 11:17:50 +00:00
Ved Chaudhari 924250dfa8 buffer: stop clamping indexOf byteOffset to int32
bidirectionalIndexOf() clamped byteOffset to the int32 range, so on
buffers larger than 2 GiB an offset above 2 ** 31 - 1 started the
search at 2 ** 31 - 1 instead. indexOf() and includes() could then
match before the requested offset, and lastIndexOf() missed matches.
Offsets below -(2 ** 31) were clamped the same way.

The binding already takes an int64 offset, so clamp to the safe
integer range instead. This still keeps Infinity and other values
that int64 can't represent from reaching the binding.

Fixes: https://github.com/nodejs/node/issues/67008
Refs: https://github.com/nodejs/node/pull/66325
Assisted-by: claude:opus-5.5
Signed-off-by: vedchaudhari <vedc2853@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67009
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-11-16 10:17:11 +00:00
sangwook c48b26c95d test_runner: add tags and workerId to SuiteContext
TestContext exposes tags and workerId, but SuiteContext does not, so a
describe() callback cannot read the suite's tags, including the ones
inherited from ancestor suites. Expose both on SuiteContext as well.

Signed-off-by: sangwook <rewq5991@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67312
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-11-16 09:47:39 +00:00
Roberto Bianchi 1a36610a71 util: use indexed writes in Set and Map inspection
Avoid the cost of primordial push calls for each formatted entry.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/67295
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-16 09:15:51 +00:00
Matteo Collina 2feb5c8aad tls: normalize session buffer views
Client sessions can be supplied as ArrayBuffer views, but session state
checks only recognize Buffers. Normalize views to Buffers before
applying those checks, preserving their byte offset and length.

This hardens session reuse handling and keeps tagged sessions reusable
when stored as typed arrays.

Assisted-by: Codex
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67251
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-16 00:31:32 +00:00
Roberto Bianchi d0d82d9990 lib: use indexed appends for dependent signals
Avoid a primordial push call for each dependent signal.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/67299
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-15 22:01:21 +00:00
Hilary Asogwa 13475276bc url: validate href setter receiver first
Validate the URL receiver before converting the assigned href value.

Fixes: https://github.com/nodejs/node/issues/67344
Signed-off-by: dansatch <dansatch98@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67350
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-15 22:01:09 +00:00