Commit Graph
48131 Commits
Author SHA1 Message Date
Shelley Vohr 875c7ecee2 node-api: enter env context for async callbacks
`uvimpl::Work::AfterThreadPoolWork()` and the thread-safe function's
`DispatchOne()` and `Finalize()` opened an
`AsyncResource::CallbackScope` with only a `HandleScope`.
`InternalCallbackScope` expects the resource's environment context to
be entered and otherwise asserts that `Environment::GetCurrent(isolate)`
is that environment, so with two environments on one isolate an addon's
async work completion or thread-safe function call aborted the process
whenever the other environment's context was current when the loop ran
the callback.

Enter the node-api env's context first, as `CallFinalizer()` and the
zlib and WebCrypto thread pool callbacks already do. In `Finalize()` the
scope covers only the finalizer call, since `MaybeDelete()` can free
the env whose persistent handle `context()` returns.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65406
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-09-15 10:49:19 +02:00
Trivikram Kamat 069a1b1200 zlib: avoid waiting for paused ZIP iterators
Track file-backed contentIterator() reads only while I/O is active.
This lets ZipFile.close() finish when an iterator is paused after
yielding a chunk, while still waiting for reads in flight.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/65278
Fixes: https://github.com/nodejs/node/issues/65277
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:19 +02:00
trivenay fce1b6a482 quic: remove unused fin flag from blob reader wakeup
The fin argument threaded from Blob::Reader::NotifyPull to the JS
blob reader iterator was dead: the only consumer, `if (fin) continue;`,
was the last statement in the loop and behaved identically to falling
through. End-of-stream is always discovered by the subsequent pull
returning EOS, never via the wakeup label. Remove the flag from the
JS iterator, NotifyPull's signature/argv, and the EndReadable call
site. The `!fin` coalescing bypass collapses safely because a parked
reader always has pull_pending_ == false, so the first wakeup after
parking always fires.

Refs: https://github.com/nodejs/node/issues/64767
Signed-off-by: Naman Trivedi <trivenay@amazon.com>
PR-URL: https://github.com/nodejs/node/pull/65315
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-09-15 10:49:18 +02:00
한국 3e6e931fc9 crypto: fix public PKCS8 export error
exportKeySpki() already rejects exporting a private key as 'spki'
with an InvalidAccessError, per the Web Crypto export key algorithm
steps for each of RSA, EC, CFRG, ML-DSA, and ML-KEM. exportKeyPkcs8()
was missing the symmetric check: exporting a public key as 'pkcs8'
fell through to the generic "Unable to export ... key using pkcs8
format" NotSupportedError instead of the spec-mandated
InvalidAccessError.

Add the same key-type check to exportKeyPkcs8(), mirroring
exportKeySpki(), and drop the now-redundant type guard around its
call site in exportKeySync(). This also fixes wrapKey(), which
delegates to the same export path.

Add test coverage for both subtle.exportKey('pkcs8', publicKey) and
subtle.wrapKey('pkcs8', publicKey, ...).

Signed-off-by: koreahghg <koreahghg@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65609
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:18 +02:00
James M Snell 6bdb6dd8fa benchmark: fix max-regressions detection in compare.js
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/65587
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-09-15 10:49:18 +02:00
Aviv Keller 56144ea80a worker: add ref/unref to web workers
Signed-off-by: avivkeller <me@aviv.sh>
PR-URL: https://github.com/nodejs/node/pull/65507
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-09-15 10:49:18 +02:00
Shelley Vohr 431c2bf0eb build: define V8_CONTIGUOUS_COMPRESSED_RO_SPACE for shared cage
Since the V8 14.2 update, `globals.h` sizes the read-only space
reservation in the shared pointer compression cage from
`V8_CONTIGUOUS_COMPRESSED_RO_SPACE_SIZE_MB`, which BUILD.gn defines
together with `V8_CONTIGUOUS_COMPRESSED_RO_SPACE` whenever
`v8_enable_pointer_compression_shared_cage` is set. features.gypi
defines neither, so builds configured with
`--experimental-pointer-compression-shared-cage` fail to compile V8.
Define both the way BUILD.gn does, with the same 16 MB default.

Refs: https://github.com/nodejs/node/pull/60254
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65464
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-09-15 10:49:18 +02:00
Antoine du Hamel 14b5dfc63d test: remove console.log call in node_run_list
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65572
Refs: https://github.com/nodejs/node/pull/65552/changes#r3862720795
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-09-15 10:49:18 +02:00
James M Snell 49d40091ba benchmark: add --analyze option to benchmark/scatter.js
Similar to compare.js, provide an R-free --analyze to
make scatter.js more self-contained.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/65594
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-09-15 10:49:18 +02:00
Paul Bouchon 6e9d44d1fe src: disable V8 external memory reasonable size check
V8 aborts the process when external memory grows by more than
--external-memory-max-reasonable-size gigabytes in a single step. The
32 GB default is a Chromium-oriented sanity check; allocating a buffer
larger than that is legitimate in Node and should raise a RangeError
rather than terminate the process.

Default the flag to 0 unless the user supplied a value, alongside the
other V8 defaults Node sets explicitly.

Fixes: https://github.com/nodejs/node/issues/65534
Signed-off-by: Paul Bouchon <mail@bitpshr.net>
PR-URL: https://github.com/nodejs/node/pull/65589
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:18 +02:00
Matteo Collina 3f67df139c test: expect node:ffi to be enabled by default
test-module-builtin-experimental was added in #65418 asserting that
node:ffi is unavailable without --experimental-ffi, but #65475 had
already enabled node:ffi by default in builds with FFI support. The two
landed independently and broke main.

Expect node:ffi to behave like node:sqlite: available by default with
the node: scheme, and gone when opted out with --no-experimental-ffi.

Refs: https://github.com/nodejs/node/pull/65418
Refs: https://github.com/nodejs/node/pull/65475
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65636
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-09-15 10:49:18 +02:00
greenhead 371e2260f4 typings: add encodeIntoResults to EncodingBinding
Signed-off-by: greenhead <shren0812@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65350
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:17 +02:00
Jungwon Sohn 54a5e25f72 module: derive builtinModules from enabled builtin set
Signed-off-by: sjungwon03 <sjungwon03@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65418
Refs: https://github.com/nodejs/node/pull/56185
Refs: https://github.com/nodejs/node/pull/56870
Refs: https://github.com/nodejs/node/pull/63158
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-09-15 10:49:17 +02:00
Filip Skokan b9ee2e67bf test: use native builder for legacy SEA tests
Migrate the remaining SEA tests away from postject. This routes ELF
generation through --build-sea, which keeps PT_LOAD segments on separate
pages for compatibility with RHEL 8 kernels.

Assisted-by: Codex
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65553
Refs: https://github.com/nodejs/build/issues/4433
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>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-15 10:49:17 +02:00
Filip Skokan d414624dce crypto: add a generic MAC API
Add getMacs() and createMac() to node:crypto as a layer on top of
OpenSSL EVP_MAC. Support incremental and streaming operations with
provider parameter validation and configurable output sizes.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65553
Refs: https://github.com/nodejs/node/issues/32433
Refs: https://github.com/nodejs/node/issues/40921
Refs: https://github.com/nodejs/node/issues/48314
Refs: https://github.com/nodejs/node/pull/32448
Refs: https://github.com/nodejs/node/pull/32477
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>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-15 10:49:17 +02:00
Trevor Burnham 5f95032859 sqlite: keep sessions alive across SQLite callbacks
Session objects are weak and nothing else holds a strong reference to
them, so a garbage collection can free one while SQLite is still using
it. SQLite runs "PRAGMA table_xinfo" from inside its pre-update hook,
which reaches JavaScript, so a GC during a callback invoked from there
can collect a session the hook is still walking.

Hold a strong reference to every attached session for the duration of
each callback SQLite invokes. The trace callback now enters that guard
before building its payload, since the allocation can itself trigger a
garbage collection.

Fixes: https://github.com/nodejs/node/issues/65460
Signed-off-by: Trevor Burnham <trevorburnham@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65465
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-09-15 10:49:17 +02:00
GetThatCookie f9175a212c http: coalesce chunked writes during auto-corking
Signed-off-by: GetThatCookie <NimmenKeks@gmx.de>
PR-URL: https://github.com/nodejs/node/pull/64987
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2026-09-15 10:49:17 +02:00
Mert Can Altin ea372bf9c9 fs: cancel in-flight stat on abort
Signed-off-by: Mert Can Altin <mertgold60@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63142
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-09-15 10:49:17 +02:00
Aryan ed1b629901 events: fix weak listener retention overwrite
The weakListeners() retention map in EventTarget stored a single
listener per retainer key. Multiple addEventListener() calls sharing
the same retainer (e.g. two listeners on one target using the same
AbortSignal) silently evicted each other's strong reference, allowing
the evicted listener to be garbage collected before its signal
aborted, so only the most recently registered listener was ever
actually removed on abort.

Changed the retention map to store a Set of listeners per retainer
key instead of a single listener, and added matching cleanup in
remove() so entries are released once their retainer's set is empty.

This also fixes the same class of bug in events.aborted() and the
streams kWeakHandler usage, since both go through the same
EventTarget.prototype.addEventListener() code path.

Fixes: https://github.com/nodejs/node/issues/63954
Signed-off-by: aryan7905 <aryansrivastava354@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64024
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-09-15 10:49:17 +02:00
Paul Bouchon 9c46e56303 src: report libuv error when openAsBlob cannot stat
`FdEntry::Create()` returned nullptr for any failed `uv_fs_stat()`,
discarding the status, and `BlobFromFilePath()` turned that into
`ERR_INVALID_ARG_VALUE: Unable to open file as blob`. A missing file is
not a malformed argument, and the resulting `TypeError` carried no
`errno`, `syscall`, or `path`, so ENOENT could not be told apart from
any other reason the path was unusable.

Thread the libuv status out of `CreateFdEntry()` and throw a
`UVException` instead, so `fs.openAsBlob()` reports the same error
`fs.stat()` does for the same path.

Fixes: https://github.com/nodejs/node/issues/65514
Signed-off-by: Paul Bouchon <mail@bitpshr.net>
PR-URL: https://github.com/nodejs/node/pull/65517
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-15 10:49:16 +02:00
Guilherme Araújo 2ce0e2eb10 sqlite: throw on disposal of an in-use session
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65449
Fixes: https://github.com/nodejs/node/issues/65447
Refs: https://github.com/nodejs/node/pull/65349
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
2026-09-15 10:49:16 +02:00
greenhead 53a29d0894 test: use common spawnSync helpers in more tests
The helpers report the command, both streams, and the exit condition
on failure, so mismatches are diagnosed consistently across tests.

Signed-off-by: greenhead <greenheadhq@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65552
Refs: https://github.com/nodejs/node/pull/65377
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-15 10:49:16 +02:00
Matteo Collina 2d2f4f6d1a ffi: enable module by default
Enable node:ffi by default in builds with FFI support. Keep
--experimental-ffi as a compatibility no-op and --no-experimental-ffi as
an opt-out. Loading the module still emits an experimental warning.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65475
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-09-15 10:49:16 +02:00
René 0e8f7b96b0 util: canonicalize namespaced tags in inspect()
Signed-off-by: Renegade334 <contact.9a5d6388@renegade334.me.uk>
PR-URL: https://github.com/nodejs/node/pull/63257
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-15 10:49:16 +02:00
Filip Skokan eef579047c crypto: validate JWK usages before key_ops
Check requested usages against the JWK public or private key type
before validating key_ops. This preserves the SyntaxError precedence
specified for RSA, EC, CFRG, ML-DSA, and ML-KEM imports.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65550
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:16 +02:00
Filip Skokan 9a9b137a24 crypto: fix private SPKI export error
Reject SPKI export of a private asymmetric key with InvalidAccessError
as required by the algorithm export steps. Let wrapKey propagate the
same export failure.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65550
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:16 +02:00
Filip Skokan 9941fb5dab crypto: fix RSA-PSS oversized salt handling
Let OpenSSL handle representable salt lengths so verification of an
impossible length resolves false. Guard values outside the native int32
parameter range to prevent SignJob from silently ignoring them.

Move the digest-size helper next to HKDF, its remaining consumer.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65550
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:16 +02:00
James M Snell c721aabfb7 quic: apply multiple fixes to flow control signaling
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode/Opus
PR-URL: https://github.com/nodejs/node/pull/65309
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2026-09-15 10:49:15 +02:00
Rafael Gonzaga 168af4d8d7 permission: block FileHandle fsync and fdatasync
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/65431
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:15 +02:00
kyungrae 09b431596a crypto: correct CCM decryption FIPS error message
Signed-off-by: kyungrae <kyungrae2002@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65450
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2026-09-15 10:49:15 +02:00
Trivikram Kamat bdcb6def4e ffi: validate DynamicLibrary getter receivers
Bind the path, symbols, and functions getter templates to the
DynamicLibrary constructor signature. This causes V8 to reject
incompatible receivers before invoking the native callbacks,
preventing them from crashing the process.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/65415
Fixes: https://github.com/nodejs/node/issues/65287
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
2026-09-15 10:49:15 +02:00
Shelley Vohr 0ec15a2a54 sea: keep ELF segments on separate pages in --build-sea output
When node itself is not position independent (the official Linux
binaries, and any build with a toolchain that does not default to PIE),
LIEF made room for the extra program header by moving the header table
into the largest gap between two PT_LOAD segments and extending the
earlier segment across that gap. Whenever the gap it picked was the one
between the read-only data and the read-write segment, whose boundary
is not page aligned, the extended segment ended inside the first page
of the next one. Linux 4.17 to 5.3, and RHEL 8's 4.18 kernel, map an
executable's segments with MAP_FIXED_NOREPLACE and refuse the second
mapping, so the single executable was killed with SIGSEGV before it ran
a single instruction ('elf segment at ... requested but the memory is
mapped already' in the kernel log). Which gap is largest depends on
section sizes, so roughly one build in three produced such binaries.

Ask LIEF to place the table after .bss for non-PIE executables instead,
which leaves every existing segment as the linker laid it out; the
output grows by the size of .bss. A test checks that no two PT_LOAD
segments of a --build-sea executable share a page.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65564
Refs: https://github.com/nodejs/build/issues/4433
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Stewart X Addison <sxa@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:15 +02:00
Trivikram Kamat 2c552cd32c quic: release stream arenas before cleanup
Release QUIC stream stats and state arena slots when the stream is
destroyed instead of from the Stream destructor.
Realm cleanup destroys QUIC binding data before draining remaining
BaseObjects, so a stream that survives until process teardown must
not need BindingData from its destructor.

HTTP/3 header callbacks can synchronously destroy their stream. Check
whether the stream was destroyed after those callbacks before accessing
its arena-backed state, and make repeated native destruction safe after
the slots have been released.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: codex:gpt-5.6-sol
PR-URL: https://github.com/nodejs/node/pull/65410
Fixes: https://github.com/nodejs/node/issues/65408
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:11 +02:00
Yeaseen 458664073e fs: fix rmSync error messages for non-ASCII paths
fs.rmSync previously embedded paths directly into
custom error messages while also passing the path
to ThrowErrnoException.

This caused duplicated paths for ASCII names and
corrupted paths for non-ASCII directory names on
Linux, and inconsistent path formatting on Windows.

Remove path concatenation from custom messages and
rely on ThrowErrnoException to attach the path safely.
Add a test to cover non-ASCII directory names.

Signed-off-by: Yeaseen <yeaseen.arafat96@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/61233
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-09-15 10:49:11 +02:00
Lazizbek Ergashev 5c680a50f4 test: add coverage for removeEventListener boolean capture
removeEventListener(type, fn, true) never matched a listener added
the same way, because removeEventListener compared
options?.capture === true directly while addEventListener flattened
a boolean third argument via validateEventListenerOptions().

The underlying fix landed independently in nodejs/node#64894 (worker:
add support for Web Workers), as a side effect of an unrelated
refactor, so this PR now only adds the regression test that would
have caught it. WPT does not cover this path: the
EventTarget-removeEventListener.any.js test is skipped in
test/wpt/status/dom/events.json.

Fixes: https://github.com/nodejs/node/issues/65244
Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65245
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-09-15 10:49:11 +02:00
Filip Skokan e6b34e6f7a crypto: harden X509Certificate state
Construct X509Certificate instances directly on the existing native
X.509 wrapper and keep lazy cached values in private state. Use a
non-throwing native brand check while preserving the existing
structured-clone behavior.

Preserve derived-constructor prototype semantics without rereading
new.target.prototype.

Add coverage for receiver validation, hidden state, prototype edge
cases, subclassing, and structured cloning through workers and message
ports.

Replace the key-only instanceof lint rule with a module-aware crypto
class guard and extend it to X509Certificate. Resolve references by
lexical binding so shadowed constructor names remain valid.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65518
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-09-15 10:49:10 +02:00
Filip Skokan a884b6ccbc crypto: optimize key slot caching
Cache constructor-known KeyObject types in the existing private slot
until a native handle is needed. Prime normal CryptoKey slot arrays
from constructor arguments while retaining the native fallback for
transferred keys.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65518
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-09-15 10:49:10 +02:00
Filip Skokan bd40a9a19a benchmark: add crypto class benchmarks
Measure construction and low-cost method paths for crypto classes whose
state is stored in native or private slots.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65518
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-09-15 10:49:10 +02:00
Nora Dossche fb512086d3 crypto: add null checks for OPENSSL_INIT_new()
Other calls in initialization code often already check for null pointers
via CHECK_NOT_NULL(). Do the same here.

Signed-off-by: ndossche <7771979+ndossche@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/63457
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-09-15 10:49:10 +02:00
Orgad Shaneh d62989dbdf http2: fix async context loss when trailers carry END_STREAM
The previous fix (f67e45e070) wrapped header/response event dispatch in
reqAsync.runInAsyncScope(), but missed the stream.push(null) call that
triggers the 'end' event. When END_STREAM arrives on a trailing HEADERS
frame (as gRPC does), the 'end' event fires in the session's async
context instead of the request's context.

Wrap stream.push(null) at end-of-stream in reqAsync.runInAsyncScope()
so that the 'end' event preserves the correct AsyncLocalStorage context.

Refs: https://github.com/nodejs/node/pull/55460
Signed-off-by: Orgad Shaneh <orgad.shaneh@audiocodes.com>
PR-URL: https://github.com/nodejs/node/pull/63814
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-09-15 10:49:10 +02:00
Matteo Collina 656504ffc0 crypto: prevent Hmac.digest() from returning uninitialized memory
Hmac.prototype._flush was aliased to Hash.prototype._flush, which
finalizes the native HMAC context but never sets the JavaScript-side
kFinalized flag. After an Hmac has been used as a stream, a subsequent
Hmac.prototype.digest() call therefore still believes the object has not
been finalized and calls into C++ a second time. On that second call the
native context has already been reset, so the digest buffer is never
written and Digest::MAX_SIZE bytes of uninitialized stack memory are
returned to JavaScript.

Hash is not affected because Hash::HashDigest caches its digest
(refs #28245); Hmac never received the equivalent protection.

Give Hmac its own _flush that sets kFinalized so repeat digest() calls
after stream use are handled by the existing DEP0206 guard. As defense
in depth, also set buf.len = 0 on the native side when the context has
already been reset so unwritten bytes can never be emitted.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/65112
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-09-15 10:49:10 +02:00
Seungmin Nam 417cdd8a77 typings: add typing for permission binding
Add type declarations for the `permission` internalBinding so
lib/internal/process/permission.js gets editor autocomplete and
type checking for `has()` and `drop()`.

Signed-off-by: seungmin Nam <nhjbest22@g.skku.edu>
PR-URL: https://github.com/nodejs/node/pull/65385
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:10 +02:00
Tim Perry 1ddb1c8934 lib: optimize async context frame activation
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65519
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-09-15 10:49:10 +02:00
Christian Aurich 6f99474912 test: deflake fastutf8stream destroy and reopen tests
Both tests read the destination file with no ordering guarantee against
the fs.write() that Utf8Stream still has in flight, so under load the
read can observe an empty file.

In test-fastutf8stream-destroy the read is issued right after destroy().
In test-fastutf8stream-reopen it is ordered on 'drain', documented as
emitted when the buffer has drained enough to allow continued writing,
which says nothing about the bytes being observable in the file. The
reopen path also emits a 'drain' of its own from a nextTick before the
write has landed.

Order both reads on 'write' instead, documented as emitted when a write
operation has completed and emitted from #release() once the underlying
write returned. In sync mode it is emitted from within write(), so the
listener is attached before the write call.

No data is lost by Utf8Stream here: re-reading the file after a failed
assertion shows the expected content. This corrects an expectation of
the tests, not the runtime.

Signed-off-by: Christian Aurich <christian.aurichzm@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65554
Refs: https://github.com/nodejs/reliability/blob/main/reports/2026-08-20.md
Refs: https://github.com/nodejs/reliability/blob/main/reports/2026-08-26.md
Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-09-15 10:49:10 +02:00
Alexander Lichter 34b38235c3 fs: add maxDepth option to glob
Signed-off-by: Alexander Lichter <github@lichter.io>
PR-URL: https://github.com/nodejs/node/pull/64003
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-09-15 10:49:09 +02:00
Rafael Gonzaga 6b565d7b2c doc: clarify security triage dispositions and permission boundaries
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/65436
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com>
2026-09-15 10:49:09 +02:00
jakecastelli 2342b2bf30 test: cover Readable.from() sync iterator errors
Signed-off-by: jakecastelli <38635403+jakecastelli@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/65515
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
2026-09-15 10:49:09 +02:00
Filip Skokan 1e455a4ffe test: support inspecting WPTs in child processes
Add WPT_INSPECT to launch one generated main-thread test with
--inspect-brk on an available port. Forward debugger stderr so an
inspector client can attach while the child is paused.

Require an exact generated test path and reject worker variants, whose
test code runs in a nested Worker. Cover backend precedence, selector
errors, inspector attachment, and clean shutdown.

Refs: https://github.com/nodejs/node/issues/51854
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65510
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:09 +02:00
Filip Skokan 1f7cab588e test: document WPT runner workflows
Describe how to run WPT modules, select source files or generated
tests, and choose the existing thread or process backend. Document the
WPTRunner options and remove duplicated run instructions.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65510
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-15 10:49:09 +02:00
James M Snell 724981287c doc: move histogram.burnRate to correct location in doc
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65434
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-09-15 10:49:09 +02:00