12775 Commits
Author SHA1 Message Date
Filip Skokan 8feccc5e22 crypto: use provider EC group names
Pass group names through EC key generation and report provider names
in key details without requiring an OpenSSL NID. Preserve established
curve aliases and synchronous invalid-curve errors.

Filter built-in curves through EC parameter generation and refresh
getCurves() results when FIPS properties change.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66108
Backport-PR-URL: https://github.com/nodejs/node/pull/66233
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:48:10 +02:00
Filip Skokan a4effe6809 crypto: use names for asymmetric key algorithms
Provider-backed keys can have no numeric OpenSSL ID. Identify and
construct asymmetric keys by algorithm name, replacing the custom PQC
name-to-NID substitution with provider-aware matching in ncrypto.

Centralize known algorithm names, public key-type names, capabilities,
and backend compatibility in ncrypto. Use named key generation jobs and
remove asymmetric EVP_PKEY constants from the internal JavaScript
binding.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/65966
Backport-PR-URL: https://github.com/nodejs/node/pull/66233
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:48:05 +02:00
Brian MuenzenmeyerandFilip Skokan ddbf974b47 crypto: add crypto.parsePKCS12()
Return the private key, end-entity certificate, and any other
non-matching certificates from a PKCS#12 (.p12/.pfx) bundle as a
KeyObject and X509Certificate instances.

Node.js already parses PKCS#12 in SecureContext::LoadPKCS12, which backs
tls's `pfx` option, but the results are consumed directly into an
SSL_CTX and never reach JavaScript. Callers who need the key or the
certificates for anything other than an immediate TLS connection have to
shell out to `openssl pkcs12` or take a userland dependency.
SecureContext::LoadPKCS12 now uses this same parsing logic.

The binding wraps d2i_PKCS12_bio() and PKCS12_parse() and follows their
semantics, matching the existing TLS path: the first private key is
returned, the end-entity certificate is the one associated with that
key, and any remaining certificates are returned through
`additionalCertificates`. A bundle containing no private key reports
`certificate` as null and returns its certificates through
`additionalCertificates`.

Absent and empty passphrases are kept distinct, since OpenSSL treats
them differently. Bundles that require OpenSSL's legacy provider throw
ERR_CRYPTO_UNSUPPORTED_OPERATION, reusing the error added for the TLS
path.

Signed-off-by: bmuenzenmeyer <brian.muenzenmeyer@gmail.com>
Co-authored-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65627
Backport-PR-URL: https://github.com/nodejs/node/pull/66233
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:48:04 +02:00
Filip Skokan 8e631aa48f crypto: add Hybrid KEMs to Web Cryptography
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65759
Backport-PR-URL: https://github.com/nodejs/node/pull/66233
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:48:01 +02:00
Filip Skokan 3f0b6d3308 lib: avoid repeat internal receiver checks
Let internal helpers access the private cache directly to avoid
repeating receiver checks.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65910
Backport-PR-URL: https://github.com/nodejs/node/pull/66233
Refs: https://github.com/nodejs/node/pull/65846
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:47:55 +02:00
Filip Skokan 0039479b4a lib: fix shared buffer growability validation
Use the intrinsic growable getter instead of buffer.growable so
shadowed properties cannot bypass validation or reject fixed buffers.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: GitHub Copilot
PR-URL: https://github.com/nodejs/node/pull/65845
Backport-PR-URL: https://github.com/nodejs/node/pull/66233
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:47:54 +02:00
Filip Skokan e7907130ae lib: use Web IDL interface brand checks
Use explicit brand predicates for interface conversion instead of
prototype ancestry. Update CryptoKey and AbortSignal together with the
shared converter contract.

Read internal AbortSignal state during composition. Preserve genuine
signals after prototype changes without invoking shadowed getters.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: GitHub Copilot
PR-URL: https://github.com/nodejs/node/pull/65846
Backport-PR-URL: https://github.com/nodejs/node/pull/66233
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:47:53 +02:00
Filip Skokan c2ec40c2d7 crypto: disable non-FIPS WebCrypto paths in FIPS mode
Hide TurboSHAKE and KangarooTwelve when FIPS is enabled. Reject cSHAKE
and KMAC parameters that require implementations outside the OpenSSL
provider, while keeping provider-backed paths available.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65172
Backport-PR-URL: https://github.com/nodejs/node/pull/66233
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:47:51 +02:00
Filip Skokan 810a6b00ee test: update tests to run with OpenSSL >= 3.0 FIPS mode
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64960
Backport-PR-URL: https://github.com/nodejs/node/pull/66233
Fixes: https://github.com/nodejs/node/issues/48379
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:47:46 +02:00
Shelley Vohr ebc028d75d trace_events: fix abort when Node.js does not own the V8 platform
Requiring `node:trace_events` and calling `createTracing()` aborted
the process, and `getEnabledCategories()` dereferenced a null pointer,
when Node.js runs on an embedder's own platform
(`kNoInitializeNodeV8Platform`): no `tracing::Agent` exists then, and
`lib/trace_events.js` only checked the compile-time `hasTracing` flag
and `ownsProcessState` before handing the null agent to the binding.

Have the binding report whether an agent exists and throw the existing
`ERR_TRACE_EVENTS_UNAVAILABLE` when it does not, as for a
`--without-v8-platform` build.

Refs: https://github.com/nodejs/node/pull/19803
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65954
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-09-25 18:01:55 +02:00
kishore280 146f00f64b child_process: clear timeout timer on spawn-time error too
When spawn() fails at the OS level (ENOENT, EACCES, EAGAIN, EMFILE,
ENFILE), the resulting ChildProcess only ever emits 'error', never
'exit'. The `timeout` option's cleanup only listened for 'exit', so
the timer stayed armed for the full `timeout` duration on any
spawn-time failure, holding the event loop open well after the
promise/callback had already settled via 'error'.

Clear the timer on 'error' as well as 'exit'.

Fixes: https://github.com/nodejs/node/issues/65504
Signed-off-by: kishore280 <maheshwarankishore@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65506
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:01:53 +02:00
Xia Chao a27db42c3e fs: coerce FileHandle.read length like fs.read
Non-number length values reached node::fs::Read, which CHECKs
IsInt32() and aborts the process. Apply length |= 0 after defaulting,
matching fs.read and fs.readSync.

Signed-off-by: Xia Chao <236466140+bun-unsafe@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/65521
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2026-09-25 18:01:53 +02:00
Aman Chadha(IVIXMMI) 1260642ace stream: destroy Duplex.from async function on early return
When an AsyncFunction passed to Duplex.from() resolves without
consuming its input, tear down the duplex so pipeline() can finish
and destroy the upstream readable.

Fixes: https://github.com/nodejs/node/issues/55077
Assisted-by: Cursor
Signed-off-by: Aman Chadha <79802170+ac-mmi@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/65963
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
2026-09-25 18:01:53 +02:00
James M Snell 5f06defdbd stream: make share budget failures detach before throwing
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/66028
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-09-25 18:01:52 +02:00
James M Snell d1c60d898d stream: update broadcast to retain buffered data with zero consumers
While the Broadcast is still open, maintain buffered data when
consumer count reaches zero

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/66028
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-09-25 18:01:52 +02:00
Carlos Vinicius ec37f934db tls: propagate singleUse to the secure context
tls.connect() sets options.singleUse, and both TLSWrap.prototype.close()
and TLSSocket.prototype._destroySSL() check _secureContext.singleUse
before closing the context. Nothing ever assigned the flag to the
context, so the check never fired and each connection's SSL_CTX stayed
alive until the JS wrapper was garbage collected. The assignment was
lost when the context configuration was extracted into
configSecureContext().

Restore it in createSecureContext(), which owns the JS wrapper the flag
is read from, and make the close idempotent: a socket that swaps its
handle, as autoSelectFamily retries do, shares a single context between
the successive TLSWraps and each of them reaches the same teardown.

Signed-off-by: Carlos Vinicius <viniciusdev.26@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66025
Fixes: https://github.com/nodejs/node/issues/66002
Refs: https://github.com/nodejs/node/pull/38116
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-09-25 18:01:52 +02:00
Filip Skokan 253784f0e9 crypto: optimize and benchmark key preparation
Optimize asymmetric key preparation with benchmark and regression
coverage for the supported input paths.

Assisted-by: GitHub Copilot, Codex
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65892
Backport-PR-URL: https://github.com/nodejs/node/pull/66092
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-25 18:01:51 +02:00
Matteo Collina 8921108175 http2: settle pending write callbacks on destroy
When a stream is destroyed while a write is still in flight, nghttp2 may
have handed the data to the socket and never report the write completion
once the stream or session tears down. That leaves the write callback
unresolved, the Writable stuck, and the event loop never drains, which
times out test-http2-close-while-writing on macOS.

Settle the in-flight write in Http2Stream._destroy by invoking its
callback with the destroy error and resetting writePending. A later
native completion callback is then a no-op because writeCb is null and
writePending is 0, so the settle is idempotent. Passing the error rather
than null also drains any buffered writes.

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

Signed-off-by: Matteo Collina <hello@matteocollina.com>
Assisted-by: pi-coding-agent
PR-URL: https://github.com/nodejs/node/pull/66016
Fixes: https://github.com/nodejs/node/issues/58252
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
2026-09-25 18:01:51 +02:00
James M Snell 63b0974d9e util: implement util.throttle
Often closely related to util.debounce use cases, this adds an
implementation of throttle(fn) .. returns a function that limits
the number of concurrent invocations of fn.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/65899
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-09-25 18:01:51 +02:00
James M Snell a3bbb5a26f util: implement debounce
I found myself using debounce quite a bit recently while
testing some recent other additions (quic and dtls testing,
perf_hooks improvements, etc). I was using an npm dependency
right up until I realized just how generally useful it is
to actually have it Just There. So, since it was a holiday
and I just felt like it... util.debounce(...)

Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65899
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-09-25 18:01:51 +02:00
James M Snell 60c3eb61bd perf_hooks: implement SlidingWindowHistogram
The current recordable `Histogram` does not maintain any sense
of time. Samples accumulate indefinitely as they are collected.
This implements a relatively simple sliding-window mechanism
that can be count or time based. The key benefit is that the
window remains fixed/bounded while samples are recorded.

The sliding window is chunk based. Internally, it maintains
a ring buffer of a fixed number of individual histograms.
When snapshot() is called, those are materialized into a
single combined histogram. As the window slides, older
chunks (and all of the samples they hold) are dropped from
the window so the window drops however many samples happened
to be in that chunk. This does mean that precision of the
window is determined by the chunk size.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/65825
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-09-25 18:01:51 +02:00
James M Snell 6b3e6f9d5c perf_hooks: implement qrde analysis support in Histogram
Implements quantile-respectful density estimate calcuation
on Histogram. Helps with tail-focused latency analysis
without retaining raw samples.

Baking this directly into Node.js, based on a 1 million
sample, 1k bin workload, this impl is roughly 150-325x
faster than performing the equivalent in Rscript.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/65806
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-09-25 18:01:50 +02:00
James M Snell 241339f072 src,lib: add util.markPromiseAsHandled
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65805
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2026-09-25 18:01:50 +02:00
Barath Raj 53b4700892 http: don't destroy socket after request completes
Aborting a ClientRequest after the request has finished sending
and the response has fully arrived has nothing left to cancel.
destroy() still called socket.destroy(err), but the resulting
'error' is emitted on a later tick. In that window,
responseKeepAlive() has already removed socketErrorListener while
handing the socket back to the agent's free pool, so the error
lands with no listener and crashes the process.

Skip the socket destroy when there is nothing left to cancel. This
matches the existing behavior of keepAlive: false requests, which
already drop any unread buffered response data in this situation.

Fixes: https://github.com/nodejs/node/issues/65938
Signed-off-by: Barath <barathraj048@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65952
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-25 18:01:50 +02:00
Yuya Inoue 7ae085552b lib: fix AbortSignal.any() abort propagation
Follow composite signal sources at construction so abort state is
propagated even without listeners, before sources can be collected.
Keep the existing weak-reference finalization and timeout cleanup.

Cover source collection before each state accessor, including nested
composites, and cleanup of unreachable listener-less dependents.

Fixes: https://github.com/nodejs/node/issues/65995
Refs: https://github.com/nodejs/node/issues/62363
Assisted-by: Codex
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66014
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2026-09-25 18:01:50 +02:00
Donghoon Kang 8aa870940c perf_hooks: reuse buffer for uv metrics
Reuse an aliased Int32Array to transfer uv metrics from C++ to
JavaScript instead of allocating a new V8 array on every access.

Assisted-by: Codex
Signed-off-by: HoonDongKang <d159123@naver.com>
PR-URL: https://github.com/nodejs/node/pull/65985
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-09-25 18:01:49 +02:00
Sankalp Thakur 9a2f77a3fc http2: fix onread assert when destroying session from stream handler
When session.destroy() runs from a 'stream' handler, MakeCallback drains
nextTick while nghttp2 is still inside mem_recv. Close is deferred for
that window (see #64166), so later HEADERS in the same buffer created
C++ streams without a JS wrapper or onread, and DATA delivery aborted
with Assertion failed: onread->IsFunction().

- Reject new streams while the session is closing
- Destroy the C++ handle if on_headers runs after JS destroy
- Drop DATA when onread is not installed (defensive)

Fixes: https://github.com/nodejs/node/issues/64850
Signed-off-by: Sankalp Thakur <sankalphimself@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65116
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-09-25 18:01:49 +02:00
Yuya Inoue b4b859319d test_runner: avoid reusing v8 serializers
A serializer must not be used after releaseBuffer() is called. Use a
dedicated instance to calculate the header length and create a new
serializer for each test event.

Add a regression test that serializes the same object twice and verifies
that both frames can be deserialized independently.

Signed-off-by: inoway46 <inoueyuya416@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/65951
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
2026-09-25 18:01:48 +02:00
Jihwan b3766225e1 test_runner: fix quote escaping in JUnit
Escape XML content before replacing double quotes and line feeds.

Add a snapshot test for repeated quotes, literal quote references,
and quotes mixed with ampersands, less-than signs, or a newline.

Signed-off-by: hanityx <hanityx@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65971
Refs: https://github.com/nodejs/node/pull/60274
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-09-25 18:01:47 +02:00
Sergey Sannikov e6832b2cb1 assert: fix TypeError on deepStrictEqual with null Map key or Set member
deepStrictEqual() and util.isDeepStrictEqual() threw "Cannot read
properties of null (reading 'constructor')" instead of comparing when
a Map key or Set member was null/undefined (or another primitive) and
lined up against object-only keys/members in the other collection with
an equal count. The primitive/null handling was gated behind an
optimization that is skipped when the counts match, letting such keys
reach objectComparisonStart, which dereferences `.constructor`.

Resolve primitive and null keys/members directly in every case.

Signed-off-by: semx <7532921+semx@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/64449
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-25 18:01:47 +02:00
Matteo Collina bbb00558c5 stream: avoid promise allocation for parked transform writes
A transform sink write arriving under backpressure parked the chunk
together with a PromiseWithResolvers record whose promise was returned
to the writable controller and later resolved with the perform-transform
promise. The writable's write reactions already exist before the write
algorithm runs, so the parked write can instead return the parked-result
sentinel and have the continuation wire the perform-transform promise
directly to those reactions, dropping the per-chunk promise record and
the thenable adoption hop. Failures while erroring are delivered in a
microtask, preserving the old rejection position.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65625
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-09-25 18:01:47 +02:00
Matteo Collina 3216bc3912 stream: keep webstream stream states in fast-mode objects
The per-stream state records were built as object literals with
__proto__: null, which V8 creates as dictionary-mode objects: roughly
50x slower to allocate, and every subsequent property load on them is a
dictionary lookup. These records back every hot path, so both stream
construction and per-chunk field accesses were paying for it.

Replace the literals with classes whose prototype has a null prototype,
so instances stay in fast mode while Object.prototype remains excluded
from the lookup chain. Every field ever assigned is declared up front
so the shape never transitions.

Also add benchmark/webstreams/lifecycle.js covering the short-lived
stream pattern (create, few chunks, close) that first exposed this.

Assisted-by: ChatGPT
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65625
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-09-25 18:01:46 +02:00
Patrick Dähne 01032f4fdc lib: fix for FileHandle.readableWebStream
Fixes FileHandle.readableWebStream in mode "byob" when reading into
a view that has a byteOffset>0 into the underlying ArrayBuffer.

Fixes: https://github.com/nodejs/node/issues/58817
Signed-off-by: Patrick Dähne <pdaehne@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/58842
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-09-25 18:01:46 +02:00
Lazizbek Ergashev 70c1415686 stream: reject closed only after sink abort settles
Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65727
Fixes: https://github.com/nodejs/node/issues/65726
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-09-25 18:01:46 +02:00
Richard Scarrott f8737b8ee5 stream: fix ERR_INVALID_STATE when cancelling Readable.toWeb()
When a web ReadableStream returned by Readable.toWeb() is cancelled
while the underlying Readable is actively producing data, a pending
onData callback can still fire after the controller has been closed
and attempt to enqueue a chunk, throwing ERR_INVALID_STATE.

Check wasCanceled in the onData handler and return early to avoid
calling controller.enqueue() on a closed controller.

Refs: https://github.com/nodejs/node/issues/54205
Signed-off-by: Richard Scarrott <riscarrott@googlemail.com>
PR-URL: https://github.com/nodejs/node/pull/62773
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-25 18:01:46 +02:00
Daijiro Wachi f3019b522a fs: throw on existing dir in cpSync with errorOnExist
cpSync() did not honor errorOnExist when the destination directory
already existed, while the asynchronous cp() does (fixed in the commit
that added test-fs-cp-async-dir-exists-error-on-exist). Mirror that
guard in the synchronous onDir() so both APIs behave identically.

Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64124
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-09-25 18:01:46 +02:00
James M Snell b44c072228 zlib: reject invalid zstd dictionaries
Signed-off-by: James M Snell <jsnell@cloudflare.com>
PR-URL: https://github.com/nodejs/node/pull/65867
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-09-25 18:01:45 +02:00
Donghoon Kang 60a9a28206 lib: avoid unsafe array iteration in cli table
Avoid unsafe array iteration because for...of relies on the
user-mutable Symbol.iterator. Use an index-based loop instead.

Signed-off-by: HoonDongKang <d159123@naver.com>
PR-URL: https://github.com/nodejs/node/pull/65838
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-09-22 17:07:42 +02:00
Wiyeong Seo cc124394cc path: remove StringPrototypeCharCodeAt from some methods of posix
Remove `StringPrototypeCharCodeAt` from `posix.resolve`,
`posix.normalize`, `posix.parse`.

PR-URL: https://github.com/nodejs/node/pull/54668
Refs: https://github.com/nodejs/node/pull/54546
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-22 16:55:43 +02:00
James M Snell d7e7308c76 zlib: improve zstd decoding across chunk boundaries
Discovered when testing some other changes that zstd was not
handling certain chunk boundaries very well. This fixes it.

- Decodes concatenated and skippable zstd frames across all
  chunk boundaries.
- Preserves rejectGarbageAfterEnd semantics.
- Reports corruption in subsequent frames.
- Handles trailing partial frame identifiers consistently.
- Covers classic sync/async and iterable APIs.
- Updated documentation and internal typings.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/65865
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-09-22 16:55:43 +02:00
Marten Richter ee80beaa9f quic: fix crash in onStreamClose
onStreamClose could crash, if this[kOwner]
was not set.

Signed-off-by: Marten Richter <marten.richter@freenet.de>
PR-URL: https://github.com/nodejs/node/pull/65861
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
2026-09-22 16:55:42 +02:00
Gürgün Dayıoğlu faa16f671c stream: amortize writable buffer compaction
Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/65847
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-22 16:55:42 +02:00
Filip Skokan 230a7fcef0 lib: optimize internal Web IDL dictionaries
Flatten dictionary members at construction while preserving inheritance
order. Skip member scans for nullish inputs without defaults or required
members, and define own descriptor properties to avoid inherited
setters.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65857
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-22 16:55:42 +02:00
Guy Bedford a7f8de6362 net: support sending net.BoundSocket to threads and child processes
This adds support for transferring net.BoundSocket instances to other
threads via the worker_threads postMessage() transfer list, and for
sending them to child processes as the sendHandle argument of
subprocess.send(), following on from the BoundSocket introduction.

A BoundSocket reserves a port synchronously at construction time.
Making it transferable means a port can be reserved on one thread or
process and the bound (but not yet listening or connected) TCP handle
handed off to another to listen or connect on, without racing on the
bind.

For threads, BoundSocket implements kTransfer/kTransferList/
kDeserialize, moving the underlying TCP handle with the same mechanism
used for net.Socket and net.Server transfer. For child processes, the
handleConversion entry reuses the same transfer protocol on the
sending side and the same _TransferredBoundSocket deserialization path
on the receiving side; the underlying transport is that of cluster's
shared-handle scheduling: SCM_RIGHTS on Unix and WSADuplicateSocket on
Windows, both of which carry bind state.

In both cases the source instance is left in the adopted state:
address(), fd() and close() throw ERR_SOCKET_HANDLE_ADOPTED. Transfer
requires an un-adopted, open TCP handle, otherwise
ERR_WORKER_HANDLE_NOT_TRANSFERABLE is thrown; pipe (path) binds are
not transferable and throw ERR_INVALID_HANDLE_TYPE when sent over IPC.
On the receiving side the local address is re-derived from the handle
rather than trusted from serialized state.

Signed-off-by: Guy Bedford <guybedford@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64725
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-22 16:55:42 +02:00
Filip Skokan f4665f1c41 crypto: validate the limit of PBKDF2 iterations
Reject iteration counts outside of OpenSSL supported range

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65704
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2026-09-22 16:55:41 +02:00
Filip Skokan 624abbecd7 crypto: use primordials in HKDF info validation
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65704
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2026-09-22 16:55:41 +02:00
Filip Skokan 7cc02b14ec lib: validate sequence iterator objects
Reject primitive iterator factory results before accessing next, as
required by GetIteratorFromMethod.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65844
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
2026-09-22 16:55:41 +02:00
Matteo Collina 6262e0b8c6 stream: create write request objects lazily
Every stream write created a WriteWrap JS object up front, even though
most writes complete synchronously via uv_try_write() and never use it.

Let stream_base_commons pass null instead of a request object.
StreamBase::Write() already creates the wrap object only when the write
does not complete synchronously; return that object to JS (which
attaches oncomplete/callback to it) and a plain error code otherwise.

Writes that complete synchronously now cross the JS/C++ boundary once
and allocate nothing. Callers that pass in a request object
(child_process IPC, webstreams adapters) behave as before.

Since Http2Stream::DoWrite() can invoke the completion callback
synchronously - before JS has attached oncomplete - such completions
are now recorded on the request object's writeStatus field and replayed
by stream_base_commons after dispatch. This also replaces a Has() plus
name-based MakeCallback() pair with a single Get().

Also pre-create the JS fields of WriteWrap instances in the object
template, as was already done for ShutdownWrap, so that they are
in-object properties.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64455
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-09-22 16:55:40 +02:00
Matteo Collina 0f0566de15 stream: allocate stream read buffers from a slab
Read buffers for streams that emit their data to JS were allocated per
read: a 64KB backing store, tracked in a map, and then - since reads
rarely fill the whole buffer - reallocated to the right size and copied.

Allocate read buffers from a 64KB slab instead. Reads reserve the
suggested size from the slab and JS receives a view over the slab's
ArrayBuffer at the read's offset, using the offset mechanism that
onStreamRead already supports. Unused reservation space is rewound when
a read returns less than was reserved, so small reads (e.g. TLS records)
share a slab.

This removes the per-read allocations, the map bookkeeping and the
resize copy.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/64455
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-09-22 16:55:40 +02:00
Tim Perry 99e41eb43a http2: error for incomplete reads on RST, auto-drain, deprecate aborted
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63249
Backport-PR-URL: https://github.com/nodejs/node/pull/66128
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-21 11:56:01 +02:00