Commit Graph
11653 Commits
Author SHA1 Message Date
Guilherme Araújo 5f602d5d91 sqlite: add ReadOptionalString helper
Use it for the dbName, table, db, source and target options so they
all treat a missing or undefined value as the default. Also mark
ReadOptionalBool and ReadOptionalString as [[nodiscard]].

Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67042
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-11-07 16:25:42 +00:00
junyup0503 66c5a027b6 http: emit 'drain' after flushing coalesced chunks
Since chunked writes are coalesced while the message is corked,
write() decides backpressure from the byte length of the buffered
chunks and sets kNeedDrain. When uncork() flushes them, net.Socket
accounts string chunks in UTF-16 code units, so with multi-byte text it
can stay below its own highWaterMark. It then never needs to drain and
never emits 'drain'. If the flushed writes complete asynchronously, the
check at the end of uncork() also runs while bytes are still pending,
so the response stalls with writableNeedDrain === true and
writableLength === 0.

Re-check the drain condition once the flushed data has been written,
unless the message or its socket has been destroyed in the meantime.

Fixes: https://github.com/nodejs/node/issues/66781
Refs: https://github.com/nodejs/node/pull/64987
Assisted-by: AI coding agent
Signed-off-by: junyup0503 <97156898+junyup0503@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/66782
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-11-07 09:33:56 +00:00
Antoine du Hamel d8e22bfdb2 test: fix test-config-json-schema with --openssl-use-def-ca-store
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67200
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-11-07 09:12:29 +00:00
Qingyu Wang 9d8a9adfe8 stream: fix pipeTo assert when writer is released during microtask
pipeTo defers each slow-path write to a microtask so it does not run
synchronously during enqueue(). A race allows the pipe to shut down and
release its writer after the write is scheduled but before it runs. The
deferred write then hits an ERR_INTERNAL_ASSERTION because
writer[[stream]] is undefined.

Skip the deferred write when shutdown has already started.

Fixes: https://github.com/nodejs/node/issues/63732
Signed-off-by: Qingyu Wang <wangqingyu.c0l1n@bytedance.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/63733
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-06 18:30:31 +00:00
Filip Skokan a10b7ecfdf test: use valid PBKDF2 inputs in domain test
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67250
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-06 12:53:33 +00:00
Guilherme Araújo 128f247ea4 sqlite: use 64-bit result APIs for UDF return values
JSValueToSQLiteResult() passed the size_t length of returned
ArrayBuffers and ArrayBufferViews to sqlite3_result_blob(), which
takes an int. Buffers larger than INT_MAX bytes were narrowed,
yielding silently truncated blobs or bogus empty text values.

Use sqlite3_result_blob64() and sqlite3_result_text64(), matching
Statement::BindValue(), so oversized values are rejected with
SQLITE_TOOBIG.

Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67089
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-11-06 11:53:45 +00:00
Christian Aurich Zanettini Martins 280798a30d watch: track all dependencies of an owner
filterFile() reads #ownerDependencies with the dependency path, but
writes the set back keyed by the owner, so each call starts a fresh set
and overwrites the previous one. An owner keeps only the last
dependency registered for it.

unfilterFilesOwnedBy() walks that set to release an owner's
dependencies, so every other one stays in #filteredFiles and
#dependencyOwners. Under `node --test --watch` a restart re-reports the
modules the test still loads, which hides it for those, but a
dependency it stopped requiring is never reported again and keeps
re-running the test.

Read #ownerDependencies with the key it is written with, and collapse
the repeated #dependencyOwners lookup in the loop, which now runs once
per dependency rather than once per owner.

Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66139
Refs: https://github.com/nodejs/node/pull/45214
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-11-06 10:35:50 +00:00
Matteo Collina be6f8f800a crypto: prevent stale OpenSSL errors
Clear errors raised by key comparison, SPKAC parsing, and JWK
import. Ensure TLS and private-key parsing only inspect errors
from their own OpenSSL calls.

Assisted-by: Codex
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67225
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-06 07:28:07 +00:00
Orgad Shaneh ec4d4c2950 dns: coalesce identical concurrent lookup() requests
When multiple callers issue dns.lookup() for the same (hostname, family,
hints, order) concurrently, only one getaddrinfo call is now dispatched
to the libuv threadpool.  All callers share the result.

getaddrinfo is a blocking call that runs on the libuv threadpool (capped
at 4 threads by default, with a slow I/O concurrency limit of 2).  When
DNS resolution is slow - e.g. ~10-20 s per call due to a misbehaving
resolver - identical requests queue behind each other, causing timeouts
that grow linearly with the number of concurrent callers:

  Before: 100 parallel lookup('host') -> 50 batches × 10 s = 500+ s
  After:  100 parallel lookup('host') -> 1 getaddrinfo  call = ~10 s

This is particularly severe on WSL, where the DNS relay rewrites QNAMEs
in responses (appending the search domain), causing glibc to discard
them as non-matching and wait for a 5s timeout per retry.

The coalescing is keyed on (hostname, family, hints, order) so lookups
with different options still get separate getaddrinfo calls.  Each
caller independently post-processes the shared raw result (applying the
'all' flag, constructing address objects, etc.).

Signed-off-by: Orgad Shaneh <orgad.shaneh@audiocodes.com>
Fixes: https://github.com/nodejs/node/issues/62503
PR-URL: https://github.com/nodejs/node/pull/62599
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-11-06 03:18:17 +00:00
Filip Skokan aead708af4 buffer: align Blob and File with Web IDL
Convert constructor arguments in Web IDL order before processing blob
parts, including inherited dictionary members and File.lastModified's
long long conversion.

Read buffer slots and copy bytes without invoking user getters, slice
methods, or species constructors. Treat detached parts as empty and
track Blob brands without invoking user getters or accepting proxies.

Keep rejecting bare SharedArrayBuffers and shared-memory views for
browser compatibility pending resolution of the union conversion rules.

Refs: https://github.com/whatwg/webidl/issues/1491
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66776
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-05 22:26:21 +00:00
Matteo Collina 4830c1180c http2: handle errors on compat push response streams
`response.createPushResponse()` wrapped the pushed stream in an
`Http2ServerResponse` without attaching an 'error' listener. Request
streams get one from `Http2ServerRequest`, but pushed streams have no
request, so a peer refusing the push with a non-clean RST_STREAM code
(e.g. REFUSED_STREAM) before the response finished emitted an unhandled
'error' on `response.stream` unless the application listened on it.

Attach `onStreamError` to the pushed stream before invoking the
callback, and make `onStreamError` tolerate the `null` request that
core sets on every stream.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67053
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-11-05 21:54:08 +00:00
Roberto Bianchi 544340a279 querystring: precompute Latin-1 escapes
Reuse precomputed escapes for Latin-1 characters instead of joining
two byte escapes on every occurrence. This reduces repeated work
when querystring and URLSearchParams serialize these characters.

Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/66756
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-11-05 19:25:00 +00:00
Guilherme Araújo 36452f15c5 http: batch body spans per parser execute
Buffer body spans in on_body() and deliver them to JS once per
execute() call instead of once per chunk. A body sent as many small
chunks no longer costs one C++ to JS call and Buffer per chunk.

Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67187
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-05 18:53:46 +00:00
Yagiz Nizipli 1a2b511427 test: cover crypto digest and HMAC caches
Check that HMAC instances duplicated from the same cached context stay
independent when their updates are interleaved, and that warmed digest
and HMAC caches follow FIPS mode changes without breaking an HMAC that
is already in progress.

Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com>
Assisted-by: Grok
PR-URL: https://github.com/nodejs/node/pull/67109
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-11-05 15:22:01 +00:00
Joyee Cheung 5e893ce072 src: do not enable the inspector during snapshot building
V8 no longer allows attaching a debuger or setting a debug context ID
during snapshot building. Avoid enabling the inspector in this case,
and reject the inspector options when the user-land --build-snapshot
is used.

Refs: https://chromium-review.googlesource.com/c/v8/v8/+/8679045
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67154
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-11-05 15:21:41 +00:00
Yuya Inoue 20daf9a4c7 http2: exclude queued data from response memory checks
Allow clients to receive responses when queued request data exceeds
maxSessionMemory, while preserving limits on received headers.

Fixes: https://github.com/nodejs/node/issues/66739
Refs: https://github.com/nodejs/node/pull/67113
Assisted-by: Codex
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67114
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-04 17:43:00 +00:00
Filip Skokan 3b209b2cd7 crypto: skip DH checks for recognized groups
Explicit DH parameters are recognized as named groups during OpenSSL
provider import, but DHPointer::check() only skips primality checks for
groups constructed by name. This makes createDiffieHellman() block for
seconds on standard MODP groups.

Query the imported key's group name to restore the legacy DH_check()
shortcut without changing key generation. Add a deterministic regression
test with randomness disabled and cover explicit and padded parameters
through the JavaScript API.

Fixes: https://github.com/nodejs/node/issues/67067
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/67071
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-11-04 09:29:22 +00:00
Filip Skokan e86ce8b975 crypto: add X509Certificate inspection getters
Expose version, subjectName, issuerName, extensions, tbs, and signature
without requiring callers to parse display strings or certificate DER.

Names include complete DER and grouped, ordered RDN attributes.
Extensions retain their order, duplicate and unknown OIDs, criticality,
and raw values. Expose the exact signed TBSCertificate bytes and the
signature octets, algorithm OID, and DER parameters.

Return fresh objects, arrays, and Buffers from the new getters, leaving
existing getter caching unchanged. Report inspection failures as
ERR_CRYPTO_INVALID_X509_CERTIFICATE.

Fixes: https://github.com/nodejs/node/issues/48730
Assisted-by: Codex
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67082
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-04 09:20:53 +00:00
Filip Skokan d36e9ba1f8 v8: support X509Certificate serialization
v8.serialize() currently rejects X509Certificate objects. Add a host
object encoding containing the certificate's DER snapshot, including
its issuerCertificate chain, and reconstruct fresh X509Certificate
objects in v8.deserialize().

Read the stored snapshot rather than the cached raw Buffer, which can
be modified by callers. Decode each certificate independently without
imposing issuer relationships on the serialized sequence.

Assisted-by: Codex
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67083
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-04 05:57:21 +00:00
fatih c085224f33 test: extend http2 cancellation coverage
Cover session reuse after canceling queued uploads, including partial
sends and destruction from a write callback. Verify that another
stream remains usable after cancellation.

Signed-off-by: Fatih Güzel <fatihguzeldev@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66784
Fixes: https://github.com/nodejs/node/issues/66742
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-04 02:23:42 +00:00
Kevin Gibbons 3930128a10 tools: require value before done in iterator results
V8 has a fast path for `{ value, done }` literals, but it must be that
order.
Also, the ES spec technically requires that order.

Assisted-by: claude:opus-5.5
Signed-off-by: Kevin Gibbons <bakkot@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66837
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2026-11-04 00:17:57 +01:00
Antoine du Hamel 4b8a9823fc Revert "benchmark: add URLSearchParams iterator consumers benchmark"
This reverts commit b2913b4b7e.

PR-URL: https://github.com/nodejs/node/pull/66837
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2026-11-04 00:15:38 +01:00
Kevin Gibbons b2913b4b7e benchmark: add URLSearchParams iterator consumers benchmark
Assisted-by: claude:opus-5.5
Signed-off-by: Kevin Gibbons <bakkot@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66837
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2026-11-03 19:56:30 +00:00
Geoffrey BoothandClaude Sonnet 5.5 6920b08cc8 deps: load amaro from dist/internal.js
amaro 1.3.0 turned dist/index.js into a thin wrapper that requires
./internal.js, where the implementation now lives. Register and
require internal.js as the built-in instead of index.js, which would
otherwise fail to resolve its sibling.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
PR-URL: https://github.com/nodejs/node/pull/66144
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2026-11-03 15:28:29 +00:00
Trivikram Kamat 76e8b64e5b vfs: forward the watchFile listener through RealFSProvider
fs.watchFile() on a path served by a real-directory mount dispatches
to RealFSProvider.watchFile(), which ignored the supplied listener and
registered an empty function instead. The user callback never fired
after the file changed, and fs.unwatchFile(path, listener) could not
match the anonymous stub, so the stat watcher's poll timer stayed
registered and kept the process alive.

Accept the listener and pass it through to fs.watchFile() so the
callback fires on change and unwatchFile() removes it by identity.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: opencode
PR-URL: https://github.com/nodejs/node/pull/66224
Fixes: https://github.com/nodejs/node/issues/66223
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-11-02 21:19:09 +00:00
gegham1 f72100b03e test: fix cluster dgram 1 test on macos
Send to localhostIPv4 instead of 0.0.0.0.
Add strict null equality assert on socket send callback error
for failing fast in such cases.

Fixes: https://github.com/nodejs/node/issues/60050
Signed-off-by: gegham1 <geghamayvazyan9@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66986
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-02 20:57:00 +00:00
Antonio Duran 5b5f38479c test: convert forEach to for of test-buffer-inheritance file
Signed-off-by: Antonio Duran <ing.antonio.duran@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67121
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-02 16:20:12 +00:00
Sergio Calderon 3b58a73828 test: replace for each with for of
Signed-off-by: Sergio Calderon <sergioo.calderonn@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67122
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-02 16:19:56 +00:00
Antonio Duran 76ede1d471 test: use spawnSyncAndAssert in nested async stack overflow test
Signed-off-by: Antonio Duran <ing.antonio.duran@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67123
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-02 16:19:43 +00:00
Jan Peer Stöcklmair 5e005dc41d test: convert .forEach to for...of
Signed-off-by: JPeer264 <jan.peer@sentry.io>
PR-URL: https://github.com/nodejs/node/pull/67124
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-02 16:19:28 +00:00
Emmanuel Florencio Trujillo d15118211d test: convert .forEach to for...of in test-net-write-arguments.js
Signed-off-by: EmmanuelFlorencioT <emmanuel.florencio.dev@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67125
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-02 16:19:14 +00:00
Raymundo Lopez Santiago cd3b484ae9 test: convert for each to for of in test/parallel/test-net-server-close
Signed-off-by: 11rls11 <raymundo.lopzantiago@outlook.com>
PR-URL: https://github.com/nodejs/node/pull/67127
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-02 16:19:02 +00:00
Raul Garcia ae37578540 test: use for...of in test-require-resolve-invalid-paths
Signed-off-by: Raul Garcia <rraulg5@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67128
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-11-02 16:18:47 +00:00
Dustin 1389475f66 quic: retain readers for readable streams
Create readers when readable QuicStream instances are constructed so
data received before the first async iterator pull survives native
stream cleanup. Add a regression test for a peer-initiated
unidirectional stream that sends data and FIN before the reader is
pulled.

Assisted-by: Codex
Signed-off-by: GiHoon1123 <rlaejrqo465@naver.com>
PR-URL: https://github.com/nodejs/node/pull/66407
Fixes: https://github.com/nodejs/node/issues/66347
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-11-02 12:22:47 +00:00
Matteo Collina 70e1db3deb stream: reject writes during WritableStream close
WritableStreamDefaultControllerProcessClose clears the controller
algorithms while the stream is still 'writable', before the sink close
settles. A write in that window, such as writer.write() after
writer.close() while the sink's close() or a TransformStream's flush()
is pending, reached the cleared size algorithm and failed an internal
assertion instead of being rejected as closing. Accept that state in
writableStreamDefaultControllerGetChunkSize so the write is rejected
with a TypeError, as it is once the stream has closed.

Refs: https://github.com/nodejs/node/issues/57272
Refs: https://github.com/whatwg/streams/issues/1341
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67058
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-11-02 08:35:07 +00:00
Matteo Collina 12065411c9 stream: keep async context of fromWeb writes
Writable.fromWeb() and Duplex.fromWeb() dispatch writes to the
WritableStream directly and complete them through a shared write
tracker. A write issued before the WritableStream had started was
queued and processed from its start step, so the sink ran in the async
context of the code that created the WritableStream, and the tracker
invoked the Node.js write callback synchronously from whatever context
completed the sink write, so the writes and final() it released ran
there too. The promise-based adapter waited for writer.ready and
received the result through a reaction, both in the context of the
Node.js write.

Dispatch writes issued before the start from a writer.ready reaction,
failing them if the stream was closed or errored meanwhile, and deliver
the write callback in the context of the Node.js write, from a reaction
when it completes in another context.

Refs: https://github.com/nodejs/node/issues/66906
Refs: https://github.com/nodejs/node/pull/65548
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67055
Refs: https://github.com/nodejs/node/pull/67052
Refs: https://github.com/nodejs/node/pull/67054
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-11-02 08:24:14 +00:00
Robert Nagy bf246cf4b5 buffer: limit UTF-8 fast calls to safe one-byte strings
Replace the allocating UTF-8 fast call with a fast binding for
sequential one-byte strings. Its slow fallback only returns a Smi
sentinel. JavaScript sends rejected strings to a separate regular
binding that can flatten strings and handle lazy deoptimization.

Both native callbacks used by the fast API avoid JS-heap allocation.
Add GC regression and string-representation coverage, including
optimized fast acceptance and rejection checks.

Fixes: https://github.com/nodejs/node/issues/66870
Refs: https://github.com/nodejs/node/pull/67134
Assisted-by: Codex
Signed-off-by: Robert Nagy <ronagy@icloud.com>
PR-URL: https://github.com/nodejs/node/pull/67136
Refs: https://github.com/nodejs/node/issues/66870
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
2026-11-01 08:22:55 +00:00
Yuya Inoue 80a74e1813 http2: release queued data memory on stream cancellation
Release the memory charged for queued outbound data when a stream is
canceled, so subsequent requests can reuse the session's memory budget.

Refs: https://github.com/nodejs/node/issues/66739
Assisted-by: Codex
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67113
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-10-31 16:26:28 +00:00
Christian Aurich Zanettini Martins d242f3d405 test: deflake test-worker-message-port-transfer-filehandle-fd0
The child closed stdin and expected the next open() to return fd 0,
but another thread can open a descriptor in between and take it.

Pass the file to the child as stdin and wrap fd 0 in a FileHandle, so
it is open from the start. After the transfer is discarded, accept an
fd 0 that was reused for another file.

Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66980
Refs: https://github.com/nodejs/reliability/issues/1701
Refs: https://github.com/nodejs/node/pull/66750
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-10-31 13:33:07 +00:00
Efe Karasakal cfea9922e7 quic: fix crypto error classification
Signed-off-by: Efe Karasakal <hi@efe.dev>
PR-URL: https://github.com/nodejs/node/pull/66968
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-10-30 20:17:16 +00:00
Livia Medeiros 1915b77157 test: remove duplicate common imports
Signed-off-by: LiviaMedeiros <livia@cirno.name>
PR-URL: https://github.com/nodejs/node/pull/67088
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2026-10-30 17:54:15 +00:00
Christian Aurich Zanettini Martins 96fd36a8b5 test: add test for concurrent first use of OpenSSL
OpenSSL 3 builds its table of algorithm names on first use. When
43d3fe9558 moved that first use after other threads had started, an
RSA-PSS key decoded while the table was being built could fail with
`ERR_OSSL_EVP_DECODE_ERROR`, and every later RSA-PSS decode in the
process failed too. #66903 reverted that change.

The new test fails if it comes back: Workers decode an RSA-PSS
certificate while the root certificate loader or a thread pool crypto
job uses OpenSSL for the first time. It is based on a reproduction by
Filip Skokan in #66903.

Refs: https://github.com/nodejs/node/pull/66903
Refs: https://github.com/nodejs/node/pull/66935
Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66966
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-10-30 17:34:42 +00:00
Livia Medeiros 97aed16adb util: use internal hexSlice directly in util.inspect()
Signed-off-by: LiviaMedeiros <livia@cirno.name>
PR-URL: https://github.com/nodejs/node/pull/66974
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-10-30 11:17:16 +00:00
Ulises Gascón a7d819a6ce tls: test the SPKI blocklist with a fixture key
Replace the test-only hooks on the crypto binding, and the process-wide
list and mutex they required on every handshake, with a fixture CA
whose public key is a permanent entry on the compiled-in blocklist. The
test now exercises the real list through full handshakes, without
--expose-internals, and the production path is a comparison against a
constant array.

The new fixtures provide two chains that contain the blocked key: a
server certificate issued by blocked-ca, and one issued by ca1 that
reuses the blocked key itself. The private key is checked in like every
other fixture key, so blocking it costs nothing. It is pinned in the
fixtures Makefile, since its digest is compiled in.

Refs: https://github.com/nodejs/node/pull/66871#discussion_r4325672378
Assisted-by: Claude, Codex
Signed-off-by: Ulises Gascon <ulisesgascongonzalez@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66949
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-10-30 09:54:04 +00:00
Filip Skokan 250037174e crypto: reject immutable random fill buffers
Prevent randomFillSync(), randomFill(), and getRandomValues() from
modifying immutable ArrayBuffers or their views.

Refs: https://github.com/nodejs/node/issues/66346
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66944
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-10-30 07:25:47 +00:00
Geoffrey Booth d699704f71 test: use registerHooks() over module.register()
Port the tests that registered async module customization hooks, via
`--loader`, `--experimental-loader` or `module.register()`, only as a
means of exercising other features to use `module.registerHooks()`
instead. This keeps the coverage for those features independent of the
async module customization hooks, which are being removed.

Tests that exist only to exercise the async module customization hooks
themselves are left as they are.

Assisted-by: Claude
Signed-off-by: Geoffrey Booth <webadmin@geoffreybooth.com>
PR-URL: https://github.com/nodejs/node/pull/67074
Refs: https://github.com/nodejs/node/pull/62395
Refs: https://github.com/nodejs/node/pull/62401
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2026-10-30 04:55:02 +00:00
Christian Aurich Zanettini Martins 8d514c7b0e fs: fix readFileSync utf8 overflow on short reads
`ReadFileUtf8()` appends reads shorter than 8 KiB to a string and only
moves to a heap buffer at the first full 8 KiB read. That buffer always
started at 64 KiB, but a pipe can deliver more than that in short reads
first, so copying the string into it overflowed the heap. With
`big_len` past `big_cap`, the next read size also underflowed.

Size the heap buffer to at least what was already read. When that is
more than 64 KiB, the buffer is full and the existing growth step
enlarges it before the next read.

Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66939
Fixes: https://github.com/nodejs/node/issues/66341
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-10-29 22:18:14 +00:00
Matteo Collina d56c163922 stream: keep async context of pipeTo watchers
The ClosedPromiseHook records that pipeTo() and tee() install as the
[[closedPromise]] of their reader and writer enqueued the watcher from
whoever settled the record. The source-closed, source-errored and
dest-errored steps of pipeTo() therefore ran in the async context of
the code that closed or errored the stream, so the destination's
close() and abort() and the source's cancel() observed the wrong
AsyncLocalStorage store. Capture the async context frame when the
hook is installed and register the reaction in it, as the spec's
promise reaction would.

Add a test that records the context each underlying source, sink and
transformer callback observes across readable, writable, transform,
pipe and tee scenarios, so scheduling shortcuts that drop the context
are caught.

Refs: https://github.com/nodejs/node/issues/66906
Refs: https://github.com/nodejs/node/pull/66424
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/67052
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-10-29 11:53:26 +00:00
Marco 1d3835e7dd zlib: avoid an extra empty zstd frame
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66161
Fixes: https://github.com/nodejs/node/issues/66078
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-10-29 08:56:52 +00:00
Marco c1cbf1f778 zlib: restart format detection when resetting Unzip
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66169
Fixes: https://github.com/nodejs/node/issues/64619
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-10-29 08:56:38 +00:00