Commit Graph
11057 Commits
Author SHA1 Message Date
Yuya Inoue 8c1a7d3172 quic: replace removed SetPrototypeV2 calls
Use SetPrototype when creating application options and transport
parameter objects. V8 15.5 removed the deprecated SetPrototypeV2
wrapper, which delegated to SetPrototype, breaking QUIC builds.

Assisted-by: Codex
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66603
Refs: https://github.com/nodejs/node/pull/66537
Refs: https://github.com/nodejs/node/pull/66602
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2026-10-10 13:49:13 +00:00
Paolo Insogna 29dd655d34 doc,lib,src: throw on missing WebAssembly or RX support
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
PR-URL: https://github.com/nodejs/node/pull/66533
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-10-10 09:25:32 +00:00
Guilherme Araújo c0daf393e4 sqlite: validate aggregate() name and options
`Database.prototype.aggregate()` cast its arguments without checking
their types, so a missing `options` leaked a raw V8 TypeError and a
non-string `name` was silently coerced. Throw `ERR_INVALID_ARG_TYPE`
like the other sqlite bindings do.

Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66463
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-10-09 15:53:53 +00:00
Joyee CheungandIgor Sheludko f92c252fe9 src, test: migrate to cppgc-owned v8::MicrotaskQueue
Co-Authored-By: Igor Sheludko <isheludko@gmail.com>
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66537
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-10-07 18:54:55 +00:00
Joyee Cheung 7e7ff40303 src,test: migrate GetPrototypeV2() to GetPrototype()
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66537
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-10-07 18:54:52 +00:00
Joyee Cheung 26cc118a75 src: update NODE_MODULE_VERSION to 152
Major V8 updates are usually API/ABI incompatible with previous
versions. This commit adapts NODE_MODULE_VERSION for V8 15.5.

Refs: https://github.com/nodejs/CTC/blob/master/meetings/2016-09-28.md
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66537
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-10-07 18:54:36 +00:00
René a7e9f3b3ae src: use native CopyArrayBufferBytes for webstream buffer copy
Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk>
PR-URL: https://github.com/nodejs/node/pull/66400
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-10-07 16:00:15 +00:00
Filip Skokan 9267ac84c0 crypto: remove key export and metadata locks
Raw and JWK getters return independently owned bytes or BIGNUMs. RSA
metadata snapshots public parameters and PSS restrictions. EC fallback
paths reconstruct or duplicate the source key. EC PKCS8 export changes
encoding flags only on its own clone.

Early OpenSSL 3 key downgrading mutated shared provider fields. Current
OpenSSL publishes separate legacy and provider conversion caches under
internal read/write locks. Ordinary DER/PEM export, equality, signing,
and key derivation already access the same keys without these locks.

Remove export and metadata acquisitions, including their coverage of V8
allocation and encoding, and remove the now-unused shared mutex storage.
Retain shared immutable key ownership. The concurrent reuse test checks
that EC PKCS8 export leaves the original flags intact.

Refs: https://github.com/nodejs/node/pull/36825
Refs: https://docs.openssl.org/3.5/man7/openssl-threads/
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66413
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-10-07 13:36:45 +00:00
Filip Skokan d2a27eec99 crypto: remove verify setup key locking
Verify configuration only copies signature bytes and reads DSA/EC order
width for P1363 conversion. Conversion constructs independent DER and
BIGNUM values. Signing and verification already run without the mutex
using separate operation contexts.

Cover cold shared public keys and worker clones with checked P1363
verification while signatures, derivation, exports, metadata queries,
and equality checks overlap.

Compare source PKCS8 encoding after workers finish. OpenSSL's ordinary
EC PKCS8 encoder temporarily changes source flags and races even on the
unmodified base. Keep WebCrypto PKCS8 exports concurrent through their
independent clones.

Refs: https://github.com/nodejs/node/pull/36825
Refs: https://github.com/nodejs/node/pull/37816
Refs: https://docs.openssl.org/3.5/man7/openssl-threads/
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66413
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-10-07 13:36:43 +00:00
Filip Skokan 3dbbdd0798 crypto: remove KEM key locking
ncrypto::KEM creates a new EVP_PKEY_CTX per operation. Parameters,
entropy, scratch buffers, and outputs are private to each call. ML-KEM
expansion finishes during import, and operations read an immutable key.
EC and X25519 retain read-only recipient keys. RSA synchronizes mutable
caches internally.

Remove the outer locks serializing jobs that share a KeyObject or
CryptoKey. Cover cold keys and worker clones across RSA, EC, X25519, and
ML-KEM, checking every resulting shared secret.

Refs: https://docs.openssl.org/3.5/man7/openssl-threads/
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66413
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-10-07 13:36:40 +00:00
Filip Skokan 4775f2b222 crypto: remove RSA-OAEP key locking
RSA_Cipher delegates to ncrypto::Rsa with a new EVP_PKEY_CTX per
operation. Padding, digests, labels, and output buffers belong to that
context. OpenSSL and BoringSSL synchronize RSA blinding and Montgomery
caches internally.

The lock was introduced for early OpenSSL 3 key downgrading that cleared
shared provider fields. Current OpenSSL publishes a separate legacy
cache under its own lock.

Cover cold shared CryptoKeys and worker clones with concurrent
encrypt/decrypt, synchronous KeyObject aliases, and checked plaintexts.

Refs: https://github.com/nodejs/node/pull/36825
Refs: https://docs.openssl.org/3.5/man7/openssl-threads/
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66413
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-10-07 13:36:37 +00:00
Filip Skokan bacbcdcf0a crypto: skip secret key mutex allocation
Secret key bytes are immutable after KeyObjectData construction. AES,
ChaCha20-Poly1305, MAC, and KDF jobs read those bytes without acquiring
KeyObjectData::mutex(), and secret-key export and equality do the same.

Do not allocate a shared mutex that none of these operations uses.
Asymmetric key mutex initialization remains eager so copies continue to
share the same lock while asymmetric acquisitions remain.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/66413
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-10-07 13:36:34 +00:00
Shelley Vohr 06c6e36ee5 tools: lint thread_local in src
Several Environments can share a thread, so state in src/ that belongs
to one of them cannot be kept in a thread_local. Add a cpplint rule
that rejects thread_local in src/ unless the declaration is marked with
NOLINTNEXTLINE(runtime/thread_local), and mark the existing uses, which
are per-thread by design.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66411
Refs: https://github.com/nodejs/node/pull/66239
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-10-07 10:56:09 +00:00
Shelley Vohr 07500390fb quic: give each BindingData its own allocator state
The ngtcp2 and nghttp3 allocators shared one thread_local state whose
BindingData pointer was set by the last BindingData that handed out an
allocator. With several Environments on a thread, memory allocated for
a session in one Environment was accounted against another's
BindingData and failed a CHECK when freed.

Give each BindingData its own heap-allocated state. nghttp3 buffers
backing external strings can be freed after the BindingData is gone,
so the state counts live allocations and is deleted once the
BindingData has been destroyed and the last of them is freed.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66411
Refs: https://github.com/nodejs/node/pull/66239
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-10-07 10:56:08 +00:00
Shelley Vohr 71a657ac22 crypto: keep the root cert store per Environment
The root cert store and the certificates set through
tls.setDefaultCACertificates() were thread_local, with a cleanup hook on
whichever Environment used TLS first. When several Environments share a
thread, setting the default CA certificates in one of them replaced the
trusted CAs of the others. Keep both on the Environment, next to its
other OpenSSL state.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66411
Refs: https://github.com/nodejs/node/pull/66239
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-10-07 10:56:07 +00:00
Trivikram Kamat 4dfcf1d2e9 sqlite: persist enableDefensive() across reopen
`enableDefensive()` updated only the live connection, so after
`close()` and `open()` the defensive flag went back to the value
passed to the constructor. Store the new value in the open
configuration so that `open()` applies it again.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/66404
Fixes: https://github.com/nodejs/node/issues/66403
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
2026-10-07 06:41:31 +00:00
Trivikram Kamat aa1bf2cc37 sqlite: throw on oversized strings instead of aborting
Several conversions from SQLite text to V8 strings passed a length of
-1 to String::NewFromUtf8(). With that length, V8 skips its length
check and aborts the process when the UTF-8 text exceeds
String::kMaxLength.

SQLite error messages embed the offending identifier or token, so
CreateSQLiteErrorImpl() could hit this. NullableSQLiteStringToValue(),
used for setAuthorizer() callback arguments and statement.columns()
metadata, had the same problem, and the authorizer also called
ToLocalChecked() on each argument.

Convert error messages with Utf8StringMaybeOneByte(), and check the
length up front in NullableSQLiteStringToValue(), so oversized strings
throw ERR_STRING_TOO_LONG as column values already do. In the
authorizer, deny the action and let the pending error reach the caller.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/66521
Fixes: https://github.com/nodejs/node/issues/66520
Fixes: https://github.com/nodejs/node/issues/66522
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-10-07 02:13:23 +00:00
James M Snell 3a4454151a http: add websocketMask() and websocketUnmask()
Add websocketMask(source, mask, output[, offset[, length]]) and
websocketUnmask(buffer, mask), which XOR data with a repeating 4-byte
key. This is the masking that WebSocket clients apply to every frame
they send (RFC 6455, Section 5.3), and that servers undo on every frame
they receive.

Userland WebSocket implementations do this either with a byte-by-byte
JS loop (undici, and ws without optional dependencies) or with the
bufferutil native addon. bufferutil is installed for only about 3% of
ws downloads and has no linux-arm64 prebuild, so almost all users run
the JS loop. The signature matches bufferutil, so existing users can
switch with a feature check, as ws did for buffer.isUtf8().

The implementation uses a V8 fast API call and processes 8-byte words,
which the compiler vectorizes. It handles overlapping source and output
views, and treats every view type as raw bytes. It is about 20x faster
than the JS loop at 1 KiB and 40x faster at 64 KiB, and faster than
bufferutil at every size from 32 bytes up.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/66335
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2026-10-06 11:36:02 +00:00
Marco Ippolito 019e869ad3 src: fix config file handling
Signed-off-by: Marco Ippolito <marcoippolito54@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66431
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
2026-10-05 16:47:39 +00:00
Marco Ippolito 3c577146aa src: mark config file as stable
Signed-off-by: Marco Ippolito <marcoippolito54@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66431
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
2026-10-05 16:47:38 +00:00
Joyee Cheung 88ec31414c Revert "deps,lib,tools: remove jitless and lite modes"
Newer version of V8 no longer supports
--allow-overwriting-for-next-flag and there's no way to
override the preset flag now. Revert the commit to allow
users to opt-in into the flags if still necessary.

This reverts commit 7e39b8781a.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66516
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2026-10-05 11:25:07 +00:00
Joyee Cheung 6cf05e7ddc src: fix external reference registration for new CFunction lifetime
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65161
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-10-04 22:38:30 +02:00
Michaël Zasso da93e7e4de src: migrate from v8::PropertyCallbackInfo<void>
Signed-Off-By: Michaël Zasso <targos@protonmail.com>
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65161
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-10-04 22:38:21 +02:00
Michaël ZassoandJoyee Cheung 45287a975f src: migrate from deprecated xxxV2 APIs
- Set/GetPrototype
- Holder

Co-Authored-by: Joyee Cheung <joyeec9h3@gmail.com>
Signed-Off-By: Michaël Zasso <targos@protonmail.com>
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65161
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-10-04 22:38:19 +02:00
Joyee Cheung aa1d7b53ac src: update NODE_MODULE_VERSION to 151
Major V8 updates are usually API/ABI incompatible with previous
versions. This commit adapts NODE_MODULE_VERSION for V8 15.2.

Refs: https://github.com/nodejs/CTC/blob/master/meetings/2016-09-28.md
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65161
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-10-04 22:37:39 +02:00
Paolo Insogna 7e39b8781a deps,lib,tools: remove jitless and lite modes
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
PR-URL: https://github.com/nodejs/node/pull/66459
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-10-04 13:25:43 +00:00
Donghoon Kang 617e082ff2 ffi: accept safe integer numbers for 64-bit arguments
Allow safe integer numbers as int64 and uint64 arguments alongside
bigint values. Reject negative numbers for uint64 and numbers outside
the safe integer range. Keep 64-bit return values as bigint.

Apply validation and conversion across the Fast API, shared-buffer,
and generic argument conversion paths.

Add coverage for Number and BigInt boundaries, invalid inputs, and
single-argument calls before and after optimization.

Signed-off-by: HoonDongKang <d159123@naver.com>
Assisted-by: Codex:Astra-medium
PR-URL: https://github.com/nodejs/node/pull/66197
Fixes: https://github.com/nodejs/node/issues/66198
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-10-03 09:51:13 +00:00
Trivikram Kamat e21f81228d src: fix --process-timeout message when exit waits
process.exit(), uncaught exceptions and unhandled rejections exit
through Environment::Exit(), which never calls OnEnvironmentStopping().
If a Worker blocked in a synchronous native call held up that exit past
the deadline, the watchdog blamed the main thread.

Check Environment::is_stopping() and report that the process did not
finish exiting instead.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/66361
Fixes: https://github.com/nodejs/node/issues/66360
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-10-03 09:51:01 +00:00
Mert Can Altin 52b68e01a0 crypto: improve random synchronous number generation performance
Instead of creating a RandomBytesJob object, it calls CSPRNG()
directly now.

Assisted-by: Claude Code
Signed-off-by: Mert Can Altin <mertgold60@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66348
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-10-03 08:32:22 +00:00
Matteo Collina 984aa0c25e async_hooks: remove legacy AsyncLocalStorage implementation
Remove the async_hooks-based AsyncLocalStorage fallback and the
--no-async-context-frame flag, making AsyncContextFrame the sole
implementation.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/63641
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2026-10-03 06:41:28 +00:00
Christian Aurich Zanettini Martins 7fab6566c0 fs: keep timestamps of files skipped by cpSync
With `force: false` and `preserveTimestamps: true`, the native
directory copy used by `cpSync()` left existing destination files in
place but still copied the source timestamps onto them. The JavaScript
walk, used by `cpSync()` with a `filter` and by `fs.cp()`, leaves
those files untouched.

Only copy the timestamps of files that were actually copied, as is
already done for their mode.

Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66305
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-10-02 22:33:38 +00:00
Trivikram Kamat 463711aa55 ffi: validate pointer ranges in optimized calls
On x64 SysV and arm64, a Fast API signature with two or more
arguments that uses only pointer and float types got no JS wrapper.
V8 then truncated pointer BigInts silently. With `-1n` or
`2n ** 64n + 5n`, cold calls threw ERR_INVALID_ARG_VALUE, while
optimized calls passed 0xffffffffffffffff or 5 to native code.

Use the argument wrapper for any signature with a pointer argument.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/66371
Fixes: https://github.com/nodejs/node/issues/66370
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-10-02 07:35:11 +00:00
Trivikram Kamat de073c56fa ffi: throw on allocation failure in toArrayBuffer()
The copy path of toArrayBuffer() allocated its backing store with
V8's default failure mode, so a large length aborted the process
with a fatal out-of-memory error. toBuffer() throws a catchable
ERR_MEMORY_ALLOCATION_FAILED for the same input.

Allocate with kReturnNull and throw ERR_MEMORY_ALLOCATION_FAILED
when the allocation fails. The memory is left uninitialized because
memcpy() fills it right after.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/66406
Fixes: https://github.com/nodejs/node/issues/66405
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-10-02 07:34:55 +00:00
René fbbf534de7 src: remove orphaned js_udp_wrap test binding
Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk>
PR-URL: https://github.com/nodejs/node/pull/66399
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
2026-10-01 23:16:46 +00:00
Trivikram Kamat cede7e6740 ffi: do not abort when a Worker stops in a callback
Stopping a Worker while it is running an FFI callback aborted the whole
process with "Callbacks cannot throw an exception". This happened on
worker.terminate(), on process.exit() inside the callback, and when the
main thread exited while the Worker was in a callback, since exit
terminates all Workers.

All three stop the Worker by terminating execution, and InvokeCallback
treated the termination as a thrown exception. Check HasTerminated()
first and return a zeroed result so the native caller can unwind.
Callbacks that throw still abort.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/66389
Fixes: https://github.com/nodejs/node/issues/66388
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-10-01 05:53:52 +00:00
Guilherme Araújo 5ebe0ebf65 sqlite: restore connection state on reopen
close() destroys the connection but keeps the DatabaseSync object, and
open() did not replay the state held on it.

An authorizer set with setAuthorizer() was not reinstalled, silently
dropping a deny-all policy. Limits written through db.limits.* reverted
to the constructor values. Extension loading was re-enabled from the
constructor ceiling rather than the current setting, so the connection
flag contradicted a previous enableLoadExtension(false), though
loadExtension() itself stayed blocked by its own check.

Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
Assisted-by: Claude Code
PR-URL: https://github.com/nodejs/node/pull/66042
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-10-01 05:39:07 +00:00
Shelley Vohr bd83a5cd7a child_process: build the default env block in one native pass
When spawn()/spawnSync() are called without options.env,
normalizeSpawnArguments() copied process.env with a spread and then
walked the copy to build the KEY=value array uv_spawn() takes.
Spreading the process.env proxy costs one enumerator callback plus a
query and a getter interceptor per variable, each doing a linear
getenv() scan and allocating; with a couple of hundred variables that
was the single largest JS-side cost of spawning a process.

Add KVStore::Pairs() (Enumerate() + Get() by default, one
uv_os_environ() pass for the real environment, skipping hidden
variables on Windows exactly like Enumerate() does), expose it as
process_wrap.getEnvPairs(), and use it for the default-environment
case. A user supplied options.env and the permission model case keep
the existing code. On Windows the same sort/first-wins-case-insensitive
filter is applied to the pairs. The variables copyProcessEnvToEnv()
propagates are part of the real environment by definition, and its
entries cannot contain null bytes, so those steps only remain on the
options.env path.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65325
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-30 13:30:42 +00:00
Kyungrae Kang d782ae67b6 sqlite: use cached strings for property keys
Signed-off-by: Kyungrae Kang <kyungrae2002@gmail.com>
Assisted-by: Codex
PR-URL: https://github.com/nodejs/node/pull/65902
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-09-30 13:30:27 +00:00
Christian Aurich Zanettini Martins b9bb1bd36c ffi: reject unsafe integers as length or offset
GetValidatedSize() checks the value against
static_cast<double>(SIZE_MAX), which rounds up to 2^64 on 64-bit
platforms. A length or offset of 2 ** 64 gets through, and the cast to
size_t after it is undefined behavior. With GCC on x64 it gives 0, so
ffi.setUint8(ptr, 2 ** 64, 42) writes to ptr instead of throwing.

Anything above Number.MAX_SAFE_INTEGER may already have been rounded
by the time it gets here, so reject those values too. The export*()
helpers already cap their length there, and so does setInt64() for
number values. SIZE_MAX is still the limit on 32-bit platforms.

When buffer.constants.MAX_LENGTH is Number.MAX_SAFE_INTEGER, as on
64-bit builds without the V8 sandbox, toBuffer() and toArrayBuffer()
now throw ERR_OUT_OF_RANGE for MAX_LENGTH + 1 instead of
ERR_BUFFER_TOO_LARGE.

Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66216
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-09-30 13:30:12 +00:00
Marco 69f3ae9e8a fs: stop recursive mkdir from retrying ENOENT forever
When mkdir() fails with ENOENT, the recursive algorithm assumes the
parent is missing, creates it and retries. On procfs mkdir() keeps
returning ENOENT although the parent exists, and under a concurrent
rmdir() the parent can disappear again, so the retry loop never
terminates: `fs.mkdirSync('/proc/x', { recursive: true })` spins at
100% CPU.

Retry a path that failed with ENOENT only once and report ENOENT the
second time, like the non-recursive call does.

Fixes: https://github.com/nodejs/node/issues/66268
Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66340
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-09-30 13:29:54 +00:00
Shelley Vohr 8bf7793f7e doc: update FreeEnvironment() notes for sibling Environments
With the FreeEnvironment() fix for sibling Environments and the handle
cleanup depth tracked per thread, only the Environment being freed
loses JavaScript while FreeEnvironment() runs the shared loop. Callbacks
of the other Environments on that loop run their JavaScript as usual.
Update embedding.md and the comment in node.h, which still describe
JavaScript as disallowed on the whole isolate.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66239
Refs: https://github.com/nodejs/node/pull/65977
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-09-30 09:30:42 +00:00
Shelley Vohr 670a0772fe src: assert that an IsolateData outlives its Environments
FreeIsolateData() while an Environment created from it is still alive
left that Environment with a dangling pointer and failed later in
unrelated code. Count the Environments using an IsolateData and CHECK
in its destructor that none are left.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66239
Refs: https://github.com/nodejs/node/pull/65977
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-09-30 09:30:41 +00:00
Shelley Vohr ae70f7e793 inspector: throw ERR_INSPECTOR_NOT_AVAILABLE without an agent
An Environment created with kNoCreateInspector threw a bare string from
inspector.Session#connect(), inspector.open() and the other Agent entry
points, so callers could not tell the condition apart by error code. Use
the ERR_INSPECTOR_NOT_AVAILABLE code that connectToMainThread() already
throws for the same situation.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66239
Refs: https://github.com/nodejs/node/pull/65977
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-09-30 09:30:40 +00:00
Shelley Vohr 6fbab72e37 src: track handle cleanup per thread, not per IsolateData
The FreeEnvironment() fix for sibling Environments keeps the depth of
nested Environment::CleanupHandles() calls on the IsolateData, so that
InternalCallbackScope can re-allow JavaScript for sibling Environments
while one of them is being freed. Environments that each have their own
IsolateData on the same isolate and loop never see that counter and
still fail with "illegal access". Environments that share a loop share a
thread, so keep the depth in a thread_local instead.

Refs: https://github.com/nodejs/node/pull/65977
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66239
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-09-30 09:30:39 +00:00
Antoine du Hamel 37a0b0dd93 src: remove HAVE_QUIC macro in favor of OPENSSL_NO_QUIC
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66373
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2026-09-30 07:39:34 +00:00
Filip Skokan fa3e4c9406 src: fix builds without SSL and SQLite
Include `quic/guard.h` independently of SQLite so builds with both
SSL and SQLite disabled define `OPENSSL_NO_QUIC` and skip the QUIC
version headers.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66372
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-30 07:10:36 +00:00
Trivikram Kamat f71d6441ce ffi: fix use-after-free in PrepareFunction
PrepareFunction() looked up the function cache before parsing the
signature. Parsing can run user getters, and a getter that calls
lib.close() clears the cache, which invalidates the iterator. For a
function that was already cached, reading it afterwards used freed
memory and crashed the process.

Look up the cache after the signature is parsed. If the library was
closed during parsing, ResolveSymbol() now throws
ERR_FFI_LIBRARY_CLOSED.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
PR-URL: https://github.com/nodejs/node/pull/66368
Fixes: https://github.com/nodejs/node/issues/66367
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2026-09-30 03:33:37 +00:00
Trivikram Kamat 9bf40b24cd sqlite: reject plans with unusable virtual table parameters
Return SQLITE_CONSTRAINT from xBestIndex() when a hidden column has
an equality constraint that is not usable at the current point in the
query plan. Accepting such a plan makes xFilter() call rows() with
null, silently dropping rows and returning an empty result, e.g. for
"SELECT DISTINCT * FROM m(t.a) JOIN t ON t.a = m.a". Cost estimates
alone cannot enforce parameter dependencies; rejecting the plan lets
SQLite pick an ordering where the parameter value is available.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: opencode
PR-URL: https://github.com/nodejs/node/pull/66215
Fixes: https://github.com/nodejs/node/issues/66214
Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
2026-09-29 23:36:16 +00:00
Guilherme Araújo c5b7a06d9b sqlite: throw on oversized string values
SQLite serves TEXT up to SQLITE_MAX_LENGTH, past what V8 can represent
as a string. V8 returns an empty handle without throwing, and the
user-defined function path then suppressed the SQLite error as if a
JavaScript exception were pending. exec() reported success for a
statement that never ran, and get() returned undefined.

Throw ERR_STRING_TOO_LONG when the value cannot be converted, and
suppress a SQLite error only when an exception is actually pending.

Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66209
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-09-29 16:58:35 +00:00
Nigro Simone d97041fff9 src: reduce InternalCallbackScope overhead
InternalCallbackScope looks up the Environment from the isolate two
times per call, inside async_context_frame::exchange, and it keeps the
prior async context frame in a v8::Global also when there is no frame,
that is the common case. Every call from native code into JS pays this:
MakeCallback, CallbackScope, AsyncWrap, Node-API.

Now the scope passes the Environment it already has, the option is read
with an inline accessor instead of copying the shared_ptr, and the
global handle is created only when the prior frame is not undefined.

benchmark/napi/make_callback, Node 26.3.0 built with and without this
change, Linux x64, 30 runs: from 202-208 ns to 155-159 ns per call.

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/66316
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-29 06:45:35 +00:00