Commit Graph
11222 Commits
Author SHA1 Message Date
Guilherme Araújo f0eb690cf1 sqlite: avoid resetting a finalized statement
run() and get() reset a cached statement pointer on exit. Throwing an
error can run an Error.prototype setter that closes the database and
frees it. Reset through the Statement, which Finalize() clears.

Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67557
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
2026-11-19 19:24:27 +00:00
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
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
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
Ethan Arrowood 88b034fa75 quic: fix h3 session close on early stream destroy
If the stream is destroyed right after sendHeaders(), nghttp3 still has
the response headers queued. On the next write it asks for the removed
stream's body, the read callback fails, and the whole session closes
without notifying the peer.

In an HTTP/3 session, before clearing nghttp3's pointer to a stream when
the stream is destroyed, shut down nghttp3's writes for that stream so
that other requests can continue to complete.

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/67446
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-19 17:13:16 +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
Michaël ZassoandJoyee Cheung 697c575af4 src,test: use non-deprecated v8::FunctionCallbackInfo::DataV2 API
Co-Authored-By: Joyee Cheung <joyeec9h3@gmail.com>
Signed-Off-By: Michaël Zasso <targos@protonmail.com>
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
PR-URL: https://github.com/nodejs/node/pull/67070
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-19 10:34:49 -05:00
Chengzhong Wu 441a758ced src: update NODE_MODULE_VERSION to 155
Major V8 updates are usually API/ABI incompatible with previous
versions. This commit adapts NODE_MODULE_VERSION for V8 15.8.

Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
Refs: https://github.com/nodejs/CTC/blob/master/meetings/2016-09-28.md
PR-URL: https://github.com/nodejs/node/pull/67070
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-19 10:33:39 -05: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
Christian Aurich Zanettini Martins d15ad82c29 quic: validate maxPayloadSize range
The maxPayloadSize option was copied into ngtcp2's
max_tx_udp_payload_size unchecked. ngtcp2 requires 1200 to 65527 and
only asserts it, so in a release build 0 gave the congestion controller
an empty initial window and the process died with SIGFPE in
ngtcp2_cc_cubic_init() when the connection was created. Values from 1
to 1199 were accepted and the session was destroyed before it opened.

Reject values outside that range when the session options are parsed,
for both connect() and listen().

Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67531
Refs: https://github.com/nodejs/node/pull/65827
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-18 21:16:54 +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
Filip Skokan 65f2246735 crypto: wire up SHAKE256 with BoringSSL
Add SHAKE256 and SHAKE-256 to name lookup and getHashes(). BoringSSL
exposes EVP_shake256() but omits it from its digest registry and does
not set EVP_MD_FLAG_XOF.

Enable uncustomized cSHAKE256 and the hybrid ML-KEM algorithms that
require SHAKE256. Release consumed XOF contexts after stream flushes to
reject update() and copy() while retaining cached digest retrieval.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/67483
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
2026-11-17 22:18:21 +00:00
Nigro Simone 2231574a44 src: do not shrink async resources on every pop
AsyncHooks::pop_async_context() calls shrink_to_fit() on
native_execution_async_resources_ after every pop. With the MSVC and
libc++ standard libraries, shrink_to_fit() on an empty std::deque frees
its storage, so every top-level callback scope allocates it again on
push and frees it on pop. libstdc++ does nothing here.

A program with the same pattern, a std::deque of the same variant going
from 0 to 1 to 0 elements, takes 136-147 ns per callback on Windows
with MSVC, and 6 ns without shrink_to_fit(). The async_ids_stack_ next
to it never shrinks either.

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/66344
Refs: https://github.com/nodejs/node/pull/66316
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.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:20 +00:00
James M Snell 2aa37623fe fs: use GetAsyncReqWrap() in the remaining async/sync bindings
Replace the repeated `if (argc > N) { req = GetReqWrap(args, N);
CHECK_NOT_NULL(req); ...` prologue of the fs bindings that select the
asynchronous path by argument count with GetAsyncReqWrap().

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67497
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-17 19:44:01 +00:00
James M Snell 72d04a64c5 fs: check permissions once in bindings with async and sync paths
Eleven fs bindings (stat, statfs, link, rename, unlink, realpath,
readdir, copyFile, chown, lchown, mkdtemp) repeated every permission
check in both the asynchronous and the synchronous branch, differing
only in whether the denial is reported through the request or thrown.
Obtain the request wrap up front with a new GetAsyncReqWrap() helper
and perform each check once with FS_THROW_IF_INSUFFICIENT_PERMISSIONS(),
which picks the reporting style based on whether the call is async.

How permission denials are reported is unchanged.

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67497
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-17 19:44:00 +00:00
James M Snell f04f249fe5 src: share snapshot Serialize()/Deserialize() logic for binding data
Eleven snapshotable binding data classes implemented Deserialize() with
the same sequence of opening a handle scope, looking up the Realm, and
recreating the binding data on the holder, and six of them implemented
Serialize() by handing over the InternalFieldInfo allocated in
PrepareForSerialization(). Add Realm::DeserializeBindingData() and
TakeInternalFieldInfo() helpers and use them.

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67497
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-17 19:43:59 +00:00
James M Snell 843a89c21b dns: share reply parsing skeleton between record parsers
The MX, CAA, TLSA, TXT, SRV, and NAPTR reply parsers each repeated the
same structure: lazily create the record dictionary template, parse the
reply, iterate the answer section filtering by record type, build and
append each record, and report ENODATA when nothing matched. Factor
that into GetRecordTemplate(), ForEachAnswer(), and AppendRecord()
helpers so each parser only contains its record-specific extraction.

Behavior is unchanged, including TLSA results being indexed by answer
position and never reporting ENODATA.

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67497
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-17 19:43:58 +00:00
James M Snell a625b01d03 crypto: add TicketHmacCtx alias for TLS ticket key callbacks
The SecureContext ticket key callback signatures repeated the same
backend-specific preprocessor block to select between EVP_MAC_CTX and
HMAC_CTX. Define the type once as TicketHmacCtx and use it instead.

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:21 +00:00
James M Snell 430e4af391 crypto: share digest length handling between HashInit overloads
The two Hash::HashInit() overloads duplicated the logic that
determines the digest length and validates the requested XOF output
length after the digest context is initialized. Move it into a shared
FinishHashInit() 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:18 +00:00
James M Snell 58fc2309f5 buffer: share search range logic between indexOf implementations
IndexOfString() and IndexOfBuffer() duplicated the computation of the
search range and the early returns for empty needles, empty haystacks,
and out-of-range offsets. Move it into a shared
GetIndexOfSearchRange() 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:16 +00:00
James M Snell 1f46b75a1e url: share URLPattern exec() and test() argument parsing
URLPattern::Exec() and URLPattern::Test() duplicated the parsing of the
input and baseURL arguments. Move it into a shared
ParseURLPatternMatchArgs() 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:13 +00:00
James M Snell 82939b556d sqlite: share SQLTagStore statement preparation
SQLTagStore::Run(), Iterate(), Get(), and All() each duplicated the
database state checks, statement preparation, and parameter binding.
Move them into a shared PrepareForExecution() 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:10 +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
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
Ilyas Shabi 6a536f95f7 diagnostics_channel: add threadpool work event
Signed-off-by: ishabi <ilyasshabi94@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65982
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
2026-11-17 09:00:19 +00:00
Node.js GitHub Bot bc6dd4081f deps: update zlib to 1.4-ec453dc
PR-URL: https://github.com/nodejs/node/pull/67475
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-11-17 00:59:15 +00:00
Tim Perry f9c1859dc0 quic: fix edge cases where stream FIN would be lost
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66759
Reviewed-By: Efe Karasakal <hi@efe.dev>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-16 20:01:30 +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
Tim Perry ca54b1f8e0 quic: fix per-session SSL leak
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66730
Reviewed-By: Efe Karasakal <hi@efe.dev>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-16 18:59:01 +00:00
James M Snell 428dd86489 src: warn when heap would exceed pointer compression limit
In builds without pointer compression, emit a process warning with
the code HEAP_EXCEEDS_POINTER_COMPRESSION_LIMIT when the heap that
survives a full garbage collection suggests that it would not fit in
the 4 GiB cage that limits the heap of each isolate when pointer
compression is enabled.

Pointer compression shrinks a heap by at most half, and by about 40%
in practice, so the warning says the heap is likely to exceed the
limit from 6.5 GiB, and that it will exceed the limit from 8 GiB.

The check runs in a GC epilogue callback for mark-compact GCs only,
is done at most once per Environment, and unregisters itself after
the warning has been scheduled. The warning can be silenced with
--disable-warning=HEAP_EXCEEDS_POINTER_COMPRESSION_LIMIT.

Assisted-by: Claude
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67468
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-16 15:54:47 +00:00
Gürgün Dayıoğlu 47d6da0884 fs,path: fix glob globstar section bounds
The last start index of each globstar-delimited body section was
computed from the non-globstar prefix counts in reverse order. When
sections have different lengths, the bound is too tight, so paths
such as `a/b/c/d/e` failed to match `**/a/b/c/**/d/**`. This affected
`path.matchesGlob()` and `exclude` patterns in `fs.glob()`.

Compute the bound from the number of non-globstar parts in the
section and every section after it.

Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
PR-URL: https://github.com/nodejs/node/pull/66738
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Efe Karasakal <hi@efe.dev>
2026-11-15 19:15:27 +00:00
Jason Zhang c07db8c5c1 src: avoid aborting on filesystem errors in node --run
`node --run` called the throwing overloads of
`std::filesystem::is_directory()` and `std::filesystem::current_path()`.
An unreadable `node_modules` directory or a removed working directory
made them throw, and the uncaught exception aborted the process.

Use the `std::error_code` overloads instead. A `node_modules/.bin` that
cannot be inspected is skipped, and a missing working directory is
reported as a regular error.

Signed-off-by: jazelly <xzha4350@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67270
Fixes: https://github.com/nodejs/node/issues/67269
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
2026-11-15 04:48:02 +00:00
Guilherme Araújo e18f10645c src: write strings to streams without flattening
StreamBase::WriteString() created a String::ValueView twice, the first
time in StringBytes::StorageSize() only to read the length. A ValueView
flattens the string, so writing a string built by concatenation, such
as the header of an HTTP response, allocated a flat copy on the V8 heap
before copying it again into the write buffer.

Read the length from the string in StorageSize(), and copy one-byte
strings that fit the stack buffer with String::WriteOneByte(), which
does not flatten. For UTF-8 the characters go to the last third of the
buffer and are converted into the rest of it: a Latin-1 character takes
at most two bytes.

Assisted-by: Claude
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67435
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Philipp Dunkel <pip@pipobscure.com>
2026-11-15 00:39:09 +00:00
Geoffrey Booth cb05e4d0c2 module: remove async module customization hooks
Remove `module.register()` (DEP0205), the `--experimental-loader` and
`--loader` flags, and the machinery that supported them: the loader
hooks worker thread, the hooks proxy, the async module customization
hook chains for resolving and loading, the internal worker class used to
run the loader thread, and the asynchronous module job linking. Module
customization is now provided only by `module.registerHooks()`, which
runs synchronously on the thread that loads the modules.

As the loader thread no longer exists, the ES module loader always loads
and links modules synchronously, so the code that handled promises and
the re-invented `require()` for imported CommonJS customized by the
async module customization hooks is removed too. `import()` still defers
evaluation of the module to a later microtask, as before.

`worker_threads.isInternalThread` is kept for compatibility and is now
always `false`; removing it is left for a future semver-major change.

The `ERR_ASYNC_LOADER_REQUEST_NEVER_SETTLED` and
`ERR_LOADER_CHAIN_INCOMPLETE` error codes are no longer used and are
documented as removed.

Tests that exist only to exercise the async module customization hooks
are removed.

Assisted-by: Claude
Signed-off-by: Geoffrey Booth <webadmin@geoffreybooth.com>
PR-URL: https://github.com/nodejs/node/pull/67090
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ilyas Shabi <ilyasshabi94@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2026-11-14 21:51:46 +00:00
Filip Skokan bd08ba304e crypto: throw on X509Certificate operation errors
X509Certificate can report failed operations as missing fields or
negative checks. Invalid validity times return "Bad time value" or
Invalid Date, making relational date comparisons return false.

Throw when required fields cannot be converted, certificate encoding or
fingerprint calculation fails, or a present AIA or EKU extension cannot
be decoded. Apply this to getters and explicit toLegacyObject() calls.
Report failed or unsupported private-key comparisons as exceptions.

For verify(), return true for 1 and false for 0. Also return false for a
wrong key type or invalid unused bits in the signature BIT STRING.
Throw for other negative results.

Use the existing conversion behavior for legacy TLS certificate objects,
which are also constructed internally during handshakes. Formatting
unrelated metadata must not cause an uncaught exception or reject an
otherwise valid connection.

Fixes: https://github.com/nodejs/node/issues/67285
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/67408
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-14 18:00:51 +00:00
Lazizbek Ergashev 52bfcaf572 tls: pop errors from failed session parsing
Signed-off-by: lazerg <lazerg2@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67212
Fixes: https://github.com/nodejs/node/issues/67204
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-14 08:07:22 +00:00
Orgad Shaneh 6368e00e91 src: give small stream reads their own buffer
Every read was carved out of the env-wide 64KB StreamReadSlab and
handed to JS as a view over it. TLS asks for exactly the decrypted
size, so the copy-on-waste path in Commit() never triggers, and any
TLS chunk that JS keeps pins the whole slab and every other read in
it. Chunks queued for seconds (e.g. audio streamed faster than real
time) get the slabs promoted, and their external memory then drives
most major GCs.

Reads asking for less than a slab now get a right-sized managed
buffer, as before the slab existed. Large reads (plain TCP, where
libuv suggests 64KB) still use the slab.

Assisted-by: Claude Code
Signed-off-by: Orgad Shaneh <orgad.shaneh@audiocodes.com>
PR-URL: https://github.com/nodejs/node/pull/67327
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-14 06:25:03 +00:00
Yuya Inoue f8ab6107a4 http2: send deferred RST_STREAM on stream destroy
close() with NO_ERROR waits for 'finish' before sending RST_STREAM.
If the body is stuck behind flow control and the stream is destroyed
first, RST_STREAM is never sent and nghttp2 keeps the stream open.
On the next WINDOW_UPDATE, OnRead finds no stream and returns 0
without EOF, so nghttp2 sends empty DATA frames until OOM. Both
client and server streams are affected.

Send the deferred RST_STREAM in _destroy(). As a backstop, return
NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE from OnRead when the stream is
gone, which nghttp2 documents as the way to reset a stream on error.

Fixes: https://github.com/nodejs/node/issues/67363
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67372
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
2026-11-14 05:16:17 +00:00
Chengzhong Wu dadf02907a src: adopt FallthroughCallback signature of Dispatchable
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
PR-URL: https://github.com/nodejs/node/pull/66653
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-13 20:16:37 +00:00
Matteo Collina 726d4d4b00 src: restore tty state on exit only if changed
ResetStdio() unconditionally writes the terminal attributes recorded at
startup back to stdin and stderr when the process exits, even when the
process never touched the terminal. This clobbers changes made in the
meantime by another process sharing the terminal: in `node -h | less`,
less switches the terminal to raw mode once it receives the first byte
of output, and node switches it back to cooked mode when it exits.

Only restore the recorded attributes when node itself changed the
terminal mode through setRawMode(), or when exiting because of a signal.
Restoring the O_NONBLOCK flag and libuv's own terminal mode reset are
unchanged.

Fixes: https://github.com/nodejs/node/issues/66440
Refs: https://github.com/nodejs/node/issues/35536
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/66753
Refs: https://github.com/nodejs/node/pull/66540
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-11-13 20:16:19 +00:00
James M Snell e256fcb78b lib: add gc options to node:bench
Adds option post-warmup and pre-sample gc options
to node:bench

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/66664
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-13 03:50:52 +00:00
Emerson Gomes 6728a1cfe0 http2: flush final GOAWAY after pending writes
Keep the native close pending when an active socket write prevents the
terminal GOAWAY from being serialized. Finish the close after the
outgoing buffers become available, preserving the requested error code.

Handle synchronous completion and transport errors without retrying
writes to a failed transport or losing the socket close notification.

Add a deterministic regression for default and custom GOAWAY codes, both
inside and outside the receive callback.

Fixes: https://github.com/nodejs/node/issues/66832
Assisted-by: Codex
Signed-off-by: Emerson Gomes <emerson.gomes@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66834
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-12 21:07:37 +00:00
fatih f4e89e70dd inspector: disconnect handles before releasing interfaces
Disconnect the thread handle while NodeInspectorClient still owns the
interface. This prevents cross-thread posts from calling
shared_from_this() after the interface's last strong reference has been
released.

Add a regression test verifying handle expiration during owner teardown.

Fixes: https://github.com/nodejs/node/issues/67079
Signed-off-by: Fatih Güzel <fatihguzeldev@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67281
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-11-12 19:15:20 +00:00
Matteo Collina 0d6d38f1e5 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-11 17:33:39 +01:00
Matteo Collina 3f3c59317e 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-11 17:33:39 +01:00
RafaelGSS ab6a046cc2 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-11 17:33:39 +01:00
Tim Perry 5ebf6adc4b 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-11 17:33:39 +01:00
Tim Perry 42213da8fd 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-11 17:33:39 +01:00
Tim Perry ae94cd890a 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-11 17:33:39 +01:00
Matteo Collina 9c6e6efa33 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-11 17:33:38 +01:00