Commit Graph
48965 Commits
Author SHA1 Message Date
Rafael Gonzaga bfeb3900a4 benchmark: fix hideStackFrames error benchmarks
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/66723
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-11-12 17:45:14 +01:00
Filip Skokan 9c2b2ade76 test: wait for shared-isolate Worker exit
Ten thousand non-blocking loop turns can finish before the Worker has
started. Use a thirty-second deadline and yield between turns while
waiting for its exit, preserving the expected exit-code assertion.

Refs: https://github.com/nodejs/reliability/issues/1687
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66722
Refs: https://github.com/nodejs/reliability/issues/1686
Refs: https://github.com/nodejs/reliability/issues/1690
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
2026-11-12 17:45:14 +01:00
Filip Skokan 44c7188a26 test: move large SQLite string cases to pummel
The oversized-string cases allocate hundreds of megabytes and can make
the ordinary statement test time out under parallel suite load. Move
all five cases unchanged to the sequential pummel suite, which also
allows more time for intensive tests.

Refs: https://github.com/nodejs/reliability/issues/1690
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66722
Refs: https://github.com/nodejs/reliability/issues/1686
Refs: https://github.com/nodejs/reliability/issues/1687
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
2026-11-12 17:45:14 +01:00
Filip Skokan 8189a563ba test: allow periodic flush to finish under load
Keep the event loop alive until the periodic write drains and let the
test runner enforce the timeout. A one-second deadline can expire while
asynchronous file I/O is still pending on a busy CI machine.

Refs: https://github.com/nodejs/reliability/issues/1690
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66722
Refs: https://github.com/nodejs/reliability/issues/1686
Refs: https://github.com/nodejs/reliability/issues/1687
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
2026-11-12 17:45:13 +01:00
Filip Skokan c01f8dfe17 test: wait for inspector restart before exit
The self-directed debug signal restarts the inspector asynchronously.
Wait for the replacement server to listen before asking the child to
exit, instead of racing startup against a zero-delay timer.

Refs: https://github.com/nodejs/reliability/issues/1687
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66722
Refs: https://github.com/nodejs/reliability/issues/1686
Refs: https://github.com/nodejs/reliability/issues/1690
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
2026-11-12 17:45:13 +01:00
Filip Skokan 2f39614d27 test: retry unready process timeout reports
Retry attempts that did not reach the blocked Worker before parsing
their report. A timeout during startup can force exit before the report
is complete. Keep the report and exit assertions once startup is ready.

Refs: https://github.com/nodejs/reliability/issues/1687
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66722
Refs: https://github.com/nodejs/reliability/issues/1686
Refs: https://github.com/nodejs/reliability/issues/1690
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
2026-11-12 17:45:13 +01:00
Rich Trott f5eb0d89f5 test: cover source-specific membership on closed sockets
Signed-off-by: Rich Trott <rtrott@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66624
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-11-12 17:45:13 +01:00
James M Snell 3b6a489cf3 stream: make stream/iter from() cancellation waits cheaper
To stay cancellable while a source is pending, from() waits for every
value of an async source through waitForNormalization(). For each value
it created a PromiseWithResolvers(), raced it against the value with
SafePromiseRace(), which wraps both in new promises, and ran an async
function with try/finally. This was the largest per-batch cost of
normalizing an async source.

Wait with a single promise and a single reaction on the value instead,
and reject that promise directly on cancellation. The outcome is
unchanged: the value's result, its rejection, or the cancellation
reason, whichever comes first, and the cancellation reason if the
normalization was cancelled by the time the value fulfills.

With an async generator yielding 16-byte chunks, pipeTo() is about
1.7x faster and iterating from() about 1.75x faster.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:13 +01:00
James M Snell efa7bb55b1 stream: share the once option for stream/iter abort listeners
stream/iter registered its one-time 'abort' listeners with a new
`{ __proto__: null, once: true }` options object every time, which can
be once per chunk (abortableNext()) or per waiting write. Use a single
shared kNullOnceOption instead. It is frozen, because signals can come
from user code and a patched addEventListener() must not be able to
change the options for every later registration.

The difference is small, since the listener registration itself costs
much more: with 300,000 16-byte chunks, pull() with a signal is about
1.7% faster, push() writes that wait with a signal about 3% faster, and
pipeTo() and bytes() with a signal are unchanged.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:13 +01:00
James M Snell d99c0416df stream: do not miss 'drain' in fromWritable()
When a write filled the classic Writable, fromWritable() recorded that
it needed to drain, but only listened for 'drain' once a later write
was queued or something waited for drain. If the Writable emitted
'drain' before that, for example because its write callback ran on a
microtask or with process.nextTick(), the event was missed and the flag
was never cleared: the next write() or writev() never settled, canWrite
stayed false and ondrain() never resolved.

Listen for 'drain' as soon as a write returns false, and keep listening
until it is emitted.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:13 +01:00
James M Snell bd793f1313 stream: construct the options passed to stream/iter transforms
pull() passes every stateless transform call a new
`{ __proto__: null, signal }` options object, which V8 creates in
dictionary mode, once per batch and transform.

Create the options with a TransformOptions constructor instead, for
stateful transforms as well so that both forms receive the same kind of
object. Each call still gets its own object, as the pipeline requires.
Its prototype is a single frozen object with no %Object.prototype% in
its chain, so a transform cannot pass state to other transforms through
it, and with a non-enumerable `constructor` so that util.inspect()
prints `TransformOptions { signal }`.

With 300,000 single-chunk batches, pull() is about 2% faster with one
stateless transform and about 8% faster with four.

This is observable: the options object's prototype is no longer null.
A new test covers the options contract, and the documentation now
describes it, including that pullSync() passes transforms no options.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:13 +01:00
James M Snell 80c84f9ac7 stream: construct stream/iter wait and merge records
The records queued when a stream/iter read, write or drain has to wait,
and merge()'s ready-queue entries, were `{ __proto__: null, ... }`
literals, which V8 creates in dictionary mode. They can be created once
per chunk: whenever the consumer is ahead of the producer, every read
waits, and with a full budget every write does.

Create them with constructors whose prototype is an empty, frozen,
null-prototype object: PendingRequest and PendingWrite (push(),
broadcast() and fromWritable()), QueuedWrite (fromWritable()) and
MergeEntry (merge()). fromWritable() drain waiters now settle through
resolve(false) instead of a per-waiter close() closure. merge() tells
error entries apart by their missing iterator rather than by a kind
string.

When every push() read waits for data, or every write waits behind a
full budget, reading or writing 16-byte chunks is about 30% faster.
fromWritable() with queued writes is about 18% faster, and merge() of
two sources about 9% faster.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:13 +01:00
James M Snell d164ecd7ff stream: construct stream/iter byte view snapshots and batch entries
createBatchEntry() and recordChunk() snapshot every chunk in a
seven-property `{ __proto__: null, ... }` literal, and every batch gets
a `{ __proto__: null, views, byteLength }` record. V8 creates such
literals in dictionary mode, which is expensive for objects created
for every chunk.

Create them with constructors whose prototype is an empty, frozen,
null-prototype object instead, as for IterResult. They have fast
properties and a single shape, and are only used internally.

Writing 1e6 16-byte chunks into a push() stream and reading them back
is about 6x faster with writeSync(), 3.7x faster with writevSync() (4
chunks per call) and 1.7x faster with string chunks.
benchmark/streams/iter-throughput-share-sync.js improves by 67-93%,
iter-throughput-share.js by 4-8%, and iter-throughput-broadcast.js
with 4 consumers by 8%. pipeTo() with small chunks is about 1.5x
faster.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:12 +01:00
James M Snell b58e5b64b5 stream: avoid per-write allocations in stream/iter writers
Every write() and writeSync() allocated a `{ __proto__: null, context }`
options object for the WebIDL chunk conversion, and for a Uint8Array
chunk a second, six-property one with [AllowShared] and
[AllowResizable]. Both are created in V8 dictionary mode.

Return Uint8Array chunks directly from the WriterChunk converter: with
[AllowShared] and [AllowResizable], the Uint8Array conversion cannot
reject a value isUint8Array() accepts and returns the same object. Use
shared, frozen conversion contexts for chunks, chunk sequences and
write options; the converters only read them to build error messages.

Writing 1e6 16-byte Uint8Array chunks into a push() stream and reading
them back is about 27% faster with writeSync() and with writevSync()
(4 chunks per call). String chunks are unaffected. Behavior and error
messages are unchanged.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:12 +01:00
James M Snell ee8d377e50 stream: create stream/iter iterator results with a constructor
The iterators of push(), share(), shareSync(), broadcast() consumers
and from() normalization created a `{ __proto__: null, done, value }`
literal for every result. V8 creates such literals in dictionary mode,
which makes them several times more expensive to create and read than
ordinary objects.

Create them with an IterResult constructor whose prototype is a single
frozen, null-prototype object instead. Results have fast properties
and a single shape, and still have no %Object.prototype% in their
prototype chain, so a polluted Object.prototype.then still cannot turn
a result into a thenable. Creating and reading a result is about 5x
faster in a microbenchmark.

benchmark/streams/iter-throughput-share-sync.js improves by 7% to 42%
(more with more consumers) and iter-throughput-share.js by 4-6%;
pipeTo() with small chunks is about 2.5% faster.

This is observable: results are no longer null-prototype objects, so
deepStrictEqual() comparisons against `{ __proto__: null, ... }` no
longer match, and util.inspect() prints them as
`IterResult { done, value }` (the prototype has a non-enumerable
`constructor` for that purpose). The five tests that compared results
that way now compare their own properties, and a new test covers the
result contract and the prototype pollution case.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:12 +01:00
James M Snell 05d9793857 stream: make endSync() optional in pipeToSync()
pipeToSync() threw ERR_INVALID_ARG_TYPE before writing anything when
the writer had no endSync() method and preventClose was not set.
endSync() is optional: the spec (pipeToSync() step 7) only calls it if
the writer has it, and pipeTo() already treats it that way. A writer
without endSync() now receives the data and is not closed. pipeToSync()
still never falls back to the async end().

This also fixes the from-sync-writev case of
benchmark/streams/iter-from-batching.js, whose writer has no endSync().

testPipeToSyncNoEndSync asserted the previous rejection and now checks
that the data is written and end() is not called. The documentation of
the writer requirements is corrected as well: only writeSync() is
required.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:12 +01:00
James M Snell a20322182b stream: keep long-lived stream/iter objects in fast mode
Object literals with `__proto__: null` are created in V8 dictionary
mode. Create the objects that live as long as a stream and are used for
every chunk with ObjectSetPrototypeOf() instead, as was done for the
share and broadcast consumer state, so that they keep fast properties:

- the iterators returned by push(), pull(), share(), shareSync() and
  broadcast() consumers, and the pull() consumer-cleanup wrapper,
- the iterators and the cancellation context used by from()
  normalization,
- the async wrapper share() uses for sync sources.

Objects created per call or per chunk (iterator results, options bags,
promise resolver records, single-use iterables) keep the literal form:
for those, setting the prototype after creation costs more than it
saves, about 2x slower in a create-and-read microbenchmark. The
fromWritable() writer is also unchanged, since V8 keeps object literals
with accessors in dictionary mode regardless.

With 200,000 16-byte chunks, pipeTo() is about 3.5% faster and pull()
with a transform or a signal about 1-1.5% faster. In
benchmark/streams/iter-throughput-share*.js, share() and shareSync()
improve by 1-4.5%; no benchmark regressed significantly.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66648
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:12 +01:00
Antoine du Hamel f0a74d23b6 build: fix gtest integration
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66735
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:12 +01:00
Filip Skokan 763587a280 tools: update OpenSSL on the selected branch
Use the selected workflow branch as the PR base and prefix PR titles
for branches other than the repository's default branch.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66704
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-11-12 17:45:12 +01:00
Jiawen Geng ca5de65787 crypto: avoid reusing randomInt() cache bytes
When an asynchronous randomInt() call finds the cache empty, it queues
itself and starts randomFill() on the shared cache buffer. A synchronous
call made before that job completes refills the same buffer with
randomFillSync() and returns values from offset 0. The completion
callback then reset the offset to 0, so the queued call and later calls
returned the bytes that synchronous calls had already used. The
threadpool job and randomFillSync() could also write the buffer at the
same time.

Fill a separate buffer asynchronously and copy it into the cache once
the job is done.

Fixes: https://github.com/nodejs/node/issues/66595
Refs: https://github.com/nodejs/node/pull/35110
Signed-off-by: Jiawen Geng <technicalcute@gmail.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/66597
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-11-12 17:45:12 +01:00
Antoine du Hamel e4f931249d tools: add read-only access in nix-changes.yml
Without it, the workflow fails on private forks.

Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66691
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-12 17:45:12 +01:00
Node.js GitHub Bot 57231f2c7c test: update WPT for WebCryptoAPI to b638c093cd
PR-URL: https://github.com/nodejs/node/pull/66689
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-11-12 17:45:11 +01:00
Kisnner Obando 1a6d5e0365 doc: correct QuicStream direction and id types
Signed-off-by: Kisnner Obando <kisnnerobando7@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66687
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-12 17:45:11 +01:00
Guilherme Araújo 8da7c4f4c6 sqlite: use shared-shape objects for result rows
`all()`, `get()` and `iterate()` built each row with the
`Object::New()` overload that takes names and values. That overload
always returns a dictionary-mode object, so no two rows shared a map
and every property read was a hash lookup.

Build rows from a `DictionaryTemplate` cached on the statement in place
of the column names, invalidated on re-prepare. Rows keep their null
prototype. Statements whose column names a template cannot express
(array indices, duplicates, non-ASCII names, which the template
interns as Latin-1) or with more than 64 columns keep the previous
path.

Add a benchmark that reads every column of each row, since the
existing ones only measure building rows.

Fixes: https://github.com/nodejs/node/issues/65799
Assisted-by: Claude
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66385
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-12 17:45:11 +01:00
Roberto Bianchi be145b610b url: reduce search params sort buffering
URLSearchParams.sort() copies both merge runs into temporary arrays.
Buffer only the left run and read the right run from the output array,
removing one scratch-array allocation and the right-run copying.

While left-side elements remain, the output cursor stays behind unread
right-side elements. Once the left run is exhausted, the right remainder
is already in place. Taking the left key on equality preserves
stability. The insertion-sort path below 50 pairs is unchanged.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/66665
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ilyas Shabi <ilyasshabi94@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:45:11 +01:00
Nigro Simone bde88e106a src: keep ALS store in AsyncResource::MakeCallback
AsyncResource saves the async context frame when it is created, and
MakeCallback() enters it with async_context_frame::Scope. Then
node::MakeCallback() opens the callback scope with an undefined frame,
so the callback never runs in the saved one. Since AsyncContextFrame is
the default, AsyncLocalStorage loses its store in these callbacks.

Pass the saved frame to InternalMakeCallback(), as the Node-API
AsyncContext already does. This also removes the Scope from every call,
with its two Environment lookups and its global handle.

Refs: https://github.com/nodejs/node/pull/66316
Refs: https://github.com/nodejs/node/issues/43038
Refs: https://github.com/nodejs/performance/issues/24
Signed-off-by: Nigro Simone <nigro.simone@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66326
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-11-12 17:45:11 +01:00
Chris Swithinbank 9ef0b7ad92 doc: clarify hex code usage in styleText docs
Signed-off-by: Chris Swithinbank <swithinbank@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66539
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-11-12 17:45:11 +01:00
Livia Medeiros 9fc002efd4 test: skip test failing when run under root
Signed-off-by: LiviaMedeiros <livia@cirno.name>
PR-URL: https://github.com/nodejs/node/pull/66666
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-11-12 17:45:11 +01:00
Antoine du Hamel a5709be4e4 Reapply "module: synchronously load most ES modules"
This reverts commit e5cae10148.

PR-URL: https://github.com/nodejs/node/pull/66786
Refs: https://github.com/nodejs/node/issues/66767
Refs: https://github.com/nodejs/node/pull/62530
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-12 17:44:59 +01:00
Matteo Collina a5bbc7b880 stream: keep async context of parked writes
A TransformStream write that parks on backpressure was resumed from
the read that lifted the backpressure, so transform(), the writes
queued behind it, and flush() ran in the reader's async context
instead of the writer's. Capture the async context frame when the
write parks and restore it while the continuation runs, matching the
context the spec's [[backpressureChangePromise]] reaction had.

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

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/66907
Backport-PR-URL: https://github.com/nodejs/node/pull/66915
Fixes: https://github.com/nodejs/node/issues/66906
Refs: https://github.com/nodejs/node/issues/66906
Refs: https://github.com/nodejs/node/pull/66907
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-11 17:28:53 +01:00
Antoine du Hamel 60b7c3d19e Working on v26.13.2
PR-URL: https://github.com/nodejs-private/node-private/pull/1050
2026-11-11 17:28:49 +01:00
Antoine du Hamel e9c277643b 2026-11-11, Version 26.13.1 'Lithium' (LTS)
This is a security release.

Notable changes:

* (CVE-2026-123863) http2: release headers when a stream is removed (Matteo Collina) – High
* (CVE-2026-123864) tls,http: prevent nested parser execution from empty writes (Matteo Collina) – High
* (CVE-2026-123865) http2: detect streams abandoned by nghttp2 (Matteo Collina) – High
* (CVE-2026-123866) http2: retain buffers until socket writes finish (Matteo Collina) – High
* (CVE-2026-123872) tls: disable resumption for mTLS with no session id context (Tim Perry) – High
* (CVE-2026-123872) tls: don't allow renegotiation or HRR to change SNI (Tim Perry) – High
* (CVE-2026-123872) tls: don't allow TLS resumption to change SNI (Tim Perry) – High
* (CVE-2026-123874) http2: retain streams during pending writes (Matteo Collina) – High
* (CVE-2026-126051) tls: fix remotely reachable TLS server crash (Tim Perry) – High
* (CVE-2026-123828) http2: avoid overflowing ALTSVC buffers (Matteo Collina) – Medium
* (CVE-2026-123867) tls: apply the CA of SNI contexts without a certificate (Matteo Collina) – Medium
* (CVE-2026-123868) http2: charge inbound DATA retained by streams to maxSessionMemory (Matteo Collina) – Medium
* (CVE-2026-123871) http: redact proxy credentials in invalid proxy URL errors (Matteo Collina) – Medium
* (CVE-2026-123875) http2: guard against null write request on cancelled stream (Matteo Collina) – Medium
* (CVE-2026-123877) https: isolate Agent TLS policy keys (Matteo Collina) – Medium
* (CVE-2026-123829) permission: do not leak denied descendants in recursive fs.watch (RafaelGSS) – Low
* (CVE-2026-123862) zlib: handle params callback after destroy (Matteo Collina) – Low
* (CVE-2026-123873) permission: check heap snapshot destination (RafaelGSS) – Low
* deps: update brotli to 1.2.1 (Node.js GitHub Bot)
* deps: update llhttp to 9.4.4 (Antoine du Hamel)
* deps: update sqlite to 3.54.1 (Node.js GitHub Bot)
* deps: update undici to 8.12.4 (Node.js GitHub Bot)

PR-URL: https://github.com/nodejs-private/node-private/pull/1050
v26.13.1
2026-11-10 19:41:03 +01:00
Tim Perry 6c85b8e371 tls: fix remotely reachable TLS server crash
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1018
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
CVE-ID: CVE-2026-126051
2026-11-10 19:35:28 +01:00
liujiahui 94b73673b8 deps: brotli: cherry-pick e230f474b87
Origin commit message:

	disable BROTLI_MODEL macro for some targets

	PiperOrigin-RevId: 827486322

Refs: https://github.com/google/brotli/commit/e230f474b87134e8c6c85b630084c612057f253e
PR-URL: https://github.com/nodejs/node/pull/61003
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2026-11-10 16:06:03 +01:00
Matteo Collina 9183db64fe http2: retain streams during pending writes
Native file responses create write requests without a JS reference to
the Http2Stream wrapper. Resetting a stream while its socket write is
pending could let GC delete the stream before WriteWrap::OnDone().

Keep a strong stream reference with each outgoing DATA buffer until the
underlying write completes.

Assisted-by: codex:gpt-5.6-sol
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1040
Refs: https://hackerone.com/reports/4150891
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
CVE-ID: CVE-2026-123874
2026-11-10 13:04:29 +01:00
Antoine du Hamel 8232390dd8 tools: use vendored trust store in shell.nix
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67318
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-11-10 09:53:22 +01:00
fa61009dc1 https: isolate Agent TLS policy keys
Encode TLS option types and values in HTTPS Agent keys so distinct trust
and identity policies cannot share sockets or cached sessions. Assign
stable identities to opaque SecureContext and callback objects.

Refs: https://hackerone.com/reports/3946081

Assisted-by: codex:gpt-5.6-sol
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Filip Skokan <panva.ip@gmail.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/1041
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1036
CVE-ID: CVE-2026-123877
2026-11-07 13:22:38 +01:00
Matteo Collina 62ae278a23 http2: charge inbound DATA retained by streams to maxSessionMemory
Inbound DATA frames delivered to JS while a stream is paused are
retained in the stream's readable buffer until the application reads
them. These were not counted against the session's maxSessionMemory, so
a peer could send many tiny DATA frames on a stream the application is
not draining and make the session retain an unbounded amount of memory,
in proportion to the number of frames rather than the bytes sent.

Charge each such DATA chunk (plus a per-chunk overhead comparable to the
Buffer view bookkeeping) against maxSessionMemory, and release it when
the stream resumes reading (ReadStart) or is destroyed (RemoveStream).
Add connection-level backpressure so the session stops reading from the
socket once it can no longer afford the inbound queued data, resuming
when the application consumes it.

Refs: https://hackerone.com/reports/4089663
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1000
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-123868
2026-11-07 13:22:31 +01:00
RafaelGSS 40d3d8ddca permission: do not leak denied descendants in recursive fs.watch
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/967
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-123829
2026-11-07 12:48:11 +01:00
Tim Perry a8d6286949 tls: disable resumption for mTLS with no session id context
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1030
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-123872
2026-11-07 12:48:11 +01:00
Tim Perry e750e1fa02 tls: don't allow renegotiation or HRR to change SNI
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1030
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-123872
2026-11-07 12:48:11 +01:00
Tim Perry 97b1357f08 tls: don't allow TLS resumption to change SNI
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1030
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-123872
2026-11-07 12:48:11 +01:00
Matteo Collina d14db811c7 http: redact proxy credentials in invalid proxy URL errors
The earlier fix to redact proxy credentials only covered the tunnel
error and the ProxyConfig.href property. Four other error paths still
interpolate the raw proxy URL, credentials included, into
ERR_PROXY_INVALID_CONFIG messages:

* lib/internal/http.js - ProxyConfig constructor when new URL() fails.
* lib/internal/http.js - parseProxyUrl when the URL contains CR or LF.
* lib/http.js - setGlobalProxyFromEnv() with an unparseable http_proxy.
* lib/http.js - setGlobalProxyFromEnv() with an unparseable https_proxy

Add a redactProxyUrl() helper that strips userinfo when parsing
succeeds and falls back to a textual strip for the unparseable cases
that reach the vulnerable paths, then route all four sites through it.

Refs: https://hackerone.com/reports/3966924
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1001
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
CVE-ID: CVE-2026-123871
2026-11-07 12:48:11 +01:00
Matteo Collina 7df134e2ce http2: retain buffers until socket writes finish
Partial writes can leave slices of a stream's queued buffers in the
session's outgoing write. Destroying the stream completes the original
write request and allows those buffers to be collected while the socket
still references them.

Retain a non-completing reference to the write request for each queued
buffer and propagate it to partial slices.

Assisted-by: pi
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1017
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-123866
2026-11-07 12:48:11 +01:00
Matteo Collina 66e72ec604 tls: apply the CA of SNI contexts without a certificate
`CertCbDone()` only installed an SNI context's CA store and client CA
list when `setSniContext()` succeeded, which requires the context to
have a certificate. A context added with `server.addContext(host,
{ ca })` was therefore ignored for client certificate verification,
and clients for that host were verified against the default context's
CA instead.

Apply the SNI context's CA whenever it configured one through
`addCACert()`, even without a certificate. A context with neither a
certificate nor its own CA still keeps the default trust store, rather
than switching to the bundled root certificates. Also report a failure
of `setSniContext()` instead of silently continuing with the default
credentials.

Refs: https://hackerone.com/reports/4103553
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1020
Reviewed-By: Tim Perry <pimterry@gmail.com>
CVE-ID: CVE-2026-123867
2026-11-07 12:48:10 +01:00
Matteo Collina 940cae5c33 tls,http: prevent nested parser execution from empty writes
An empty write on a TLS socket calls `ClearOut()` directly, even when
it comes from JS that runs inside `Cycle()`, for example the HTTP
parser's `on_body`. `ClearOut()` then decrypts the next record and
passes it to the same listener while it is still processing the
current one. For an HTTPS server this runs `llhttp_execute()` inside
itself. The nested call can stop in the middle of a body chunk and
leave the open span pointing into its own buffer, which is freed when
it returns. The outer call then reports that span against its own
buffer, so the request body contains server heap memory, or the
process aborts.

Skip the read on an empty write while a cycle is running. The cycle
reads the next record once the listener has returned.

In the HTTP parser, re-entrant `Execute()` calls remain supported, but
each call now restores the caller's buffer when it returns, and data
callbacks fail with `HPE_REENTRANT_EXECUTE` when they point outside the
buffer that is being executed.

Refs: https://hackerone.com/reports/4150886
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1021
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Tim Perry <pimterry@gmail.com>
CVE-ID: CVE-2026-123864
2026-11-07 12:48:10 +01:00
Matteo Collina 0ff0cf6749 http2: release headers when a stream is removed
When a peer sends more header fields than `maxHeaderListPairs`, the
stream is reset and the fields it had already accepted stay in
`current_headers_`. Each of them holds nghttp2 buffers. `RemoveStream()`
adjusted the session memory accounting but kept the headers.

A destroyed stream that still has a write on the socket is not detached
and can be collected after its session. The session destructor only
detaches the streams it still knows about, so the nghttp2 memory held
by the removed stream is still allocated and
`CHECK_EQ(current_nghttp2_memory_, 0)` aborts the process. A client can
trigger this with a single connection.

Clear the headers in `RemoveStream()`, while the session is still
alive, and in the session destructor for the streams that are still
registered, since `Detach()` does not free a stream that is referenced
elsewhere.

Refs: https://hackerone.com/reports/4150893
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1026
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
CVE-ID: CVE-2026-123863
2026-11-07 12:48:10 +01:00
Matteo Collina 6c223db6e2 zlib: handle params callback after destroy
When params() queues its flush behind another write, destroying the
stream invokes the flush callback after the native handle is closed.
Propagate the write error instead of accessing the closed handle.

Assisted-by: Codex
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1037
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-123862
2026-11-07 12:48:10 +01:00
Matteo Collina a84a01ddb8 http2: avoid overflowing ALTSVC buffers
Http2Session::AltSvc allocated origin and field-value buffers at their
exact lengths but requested V8 to append a null terminator. This wrote
one byte past heap-backed buffers.

nghttp2_submit_altsvc() consumes explicit lengths and makes its own
terminated copies. Write only the string contents.

Assisted-by: OpenAI Codex
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs-private/node-private/pull/1035
Reviewed-By: Tim Perry <pimterry@gmail.com>
CVE-ID: CVE-2026-123828
2026-11-07 12:48:10 +01:00
Antoine du Hamel e315236158 deps: update llhttp to 9.4.4
PR-URL: https://github.com/nodejs-private/node-private/pull/1038
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-11-07 12:48:10 +01:00