This is not impactful in any way - it's a fixed leak of the openssl
record compression descriptors, about 24 bytes leaked total, once
per process. Not meaningful.
It is annoying if you want to run with ASAN & leak detection though,
since it's an unambiguous leak we trigger every time crypto is used.
Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66600
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
GetLinkedBinding() reads module.exports after it calls the register
function of a linked binding. If the register function threw, that V8
API call clears the pending exception (PrepareForExecutionScope), so
the error never reaches the caller of process._linkedBinding(), which
gets the empty exports object instead. This affects every linked
binding, including Node-API ones, whose module registration already
rethrows the error of the initializer.
Addons loaded with process.dlopen() are not affected, because DLOpen()
does not call into V8 after the register function. Rethrow the error
before reading module.exports.
Signed-off-by: René Larch <renelarch@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67571
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Vladimir Morozov <vmorozov@microsoft.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
StatementIterator::Return() and SQLTagStore::ResetAndBindStatement()
called sqlite3_reset() without a SteppingStatementGuard. Resetting a
statement with an open virtual-table cursor runs the generator's
finally block, and that JavaScript can reset the same statement
again. SQLite then halts the VM a second time while the cursor slot
still points at the cursor, so xClose frees the same NodeVTabCursor
twice.
Hold the stepping guard across those resets so the re-entrant call
fails with "statement is already being executed" instead of closing
the cursor again. Ignore a second xClose on a cursor that is already
closing.
Assisted-by: Cursor Grok 4.7
Signed-off-by: gengjiawen <technicalcute@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67540
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Database opened database files without consulting the permission
model, so code running with --permission could read and write any
database regardless of --allow-fs-read and --allow-fs-write.
Check read access, and write access unless the database is read-only,
before opening a file-backed database. In-memory databases are exempt.
SQLite also opens journal, WAL and temporary files, and ATTACH and
backup() open further databases, so route every connection through a
VFS shim that checks each path SQLite opens, deletes or probes.
Reject URI filenames that select a VFS, since that would bypass the
shim, and deny ATTACH when SQLite does not pass the filename to the
authorizer.
Refs: https://hackerone.com/reports/3686625
Co-authored-by: Guilherme Araújo <arauujogui@gmail.com>
Assisted-by: Claude Code
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62957
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
compose() only listened for 'data' and 'end' on the last stream it was
given. When that stream emitted 'error' after its writable side had
already finished, pipeline() had already removed its own error listener,
so the error reached no listener and was raised as an unhandled 'error'
event, crashing the process.
Forward tail errors to the composed Duplex by destroying it whenever the
tail errors before the composition has been destroyed.
Signed-off-by: Matteo Collina <matteo.collina@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67674
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
When a process is interrupted using `--process-timeout`, the output
would print the resources and stack of the main thread. If the
thing keeping the process alive was a worker thread, or if the
worker thread was interrupted, there was no diagnostic output.
This adds an additional `--process-timeout-worker-stacks` flag
that includes the worker details. We don't necessarily want to
include workers every time because if there's a large number of
workers the output could become quite noisy.
Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Claude
PR-URL: https://github.com/nodejs/node/pull/67712
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
In node:stream/consumers, arrayBuffer() (also used by buffer() and
bytes()) collected stream chunks into a temporary Blob and then read
them back out asynchronously via blob.arrayBuffer(). For binary
streams this copied every chunk twice, allocated an intermediate copy,
and queued a microtask per chunk.
Add a fast path that concatenates chunks directly into a single
ArrayBuffer when all chunks are non-resizable ArrayBuffer-backed
Uint8Arrays (including Buffers) within kMaxLength, falling back to
Blob for all other chunk types. Behavior is unchanged.
Signed-off-by: Yaroslav Chuhai <yaroslavchugai@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67714
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
The flowing fast path keeps the prefetched chunk off the buffer and
resets `state.length` before each `_read()`. A chunk put on the buffer
by `unshift()` or `push()` from a 'data' listener while a prefetched
chunk was pending was not accounted for, so it was never delivered and
the stream ended with data still buffered.
Move the prefetched chunk onto the buffer before `unshift()` and
`push()` add to it. That keeps the chunks in order and makes the fast
path fall back to `read()`.
Also leave the fast push mode when `_read()` calls `unshift()`,
`read()` or `setEncoding()`. A following `push()` then adds to the
buffer and goes through the decoder instead of overwriting
`state.length` or delivering an undecoded chunk.
Signed-off-by: jakecastelli <38635403+jakecastelli@users.noreply.github.com>
Assisted-by: claude:fable-5.2
PR-URL: https://github.com/nodejs/node/pull/67599
Fixes: https://github.com/nodejs/node/issues/67598
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Stream operators given an already-aborted signal resolved instead of
rejecting when the stream was empty, because the signal was only
checked once a chunk arrived. Check it up front in map() and toArray(),
which the other operators are built on.
Signed-off-by: vedchaudhari <vedc2853@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67637
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
readCentralDirectory() appends one CentralFileHeader per archive entry
with ArrayPrototypePush, which is listed among primordials with known
performance issues. Assign by the existing loop index instead. The
loop runs once per entry, so its trip count grows with archive size.
The change is limited to this loop. Validation and error behavior are
unchanged.
Assisted-by: Claude Code
Signed-off-by: Roberto Bianchi <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/67456
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
The description of response.writeProcessing() was copied from
response.writeContinue() and said that the request body should be
sent, which is what 100 Continue means, not 102 Processing.
Describe what 102 means, document the callback that both methods
have always accepted, and point to the equivalent
response.writeInformation() call.
Signed-off-by: inoway46 <inoueyuya416@gmail.com>
Assisted-by: Claude Code
PR-URL: https://github.com/nodejs/node/pull/67705
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Tim Perry <pimterry@gmail.com>
getpeername(2) on a Unix domain socket returns the path the peer is
bound to, but the pipe handle had no getpeername method, so
socket.remoteAddress was always undefined for pipe connections.
Add getpeername to the pipe handle, backed by uv_pipe_getpeername(), so
that socket.remoteAddress reports the listening path on the connecting
side and the path of a bound client on the accepting side. It remains
undefined for an unbound peer, and on Windows, where a named pipe has a
single name rather than one per end.
Signed-off-by: Guy Bedford <guybedford@gmail.com>
Assisted-by: Claude Fable 5.2
PR-URL: https://github.com/nodejs/node/pull/67402
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
The sync fs, fs dir, AsyncWrap and vm.Script tracing guards called
TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED directly, which does a
by-name search in the tracing controller on every call. Use
TRACE_EVENT_CATEGORY_ENABLED instead, which caches the category
pointer per call site like the other TRACE_EVENT macros. Perfetto
already provides it; add an equivalent for the legacy tracing build.
Assisted-by: claude:opus-5.5
Signed-off-by: Gürgün Dayıoğlu <hey@gurgun.day>
PR-URL: https://github.com/nodejs/node/pull/67502
Reviewed-By: James M Snell <jasnell@gmail.com>
A free socket with an idle timeout is normally destroyed by its timer.
When the event loop is blocked long enough for that timeout to expire,
the timer cannot run, and `addRequest()` can reuse the socket even
though the server may already have closed the connection. This can
cause the request to fail with `ECONNRESET`.
Record when a socket enters the free pool and, before reuse, remove and
destroy a free socket whose idle timeout has expired according to the
timers' clock.
Refs: https://github.com/nodejs/node/issues/54293
Assisted-by: a closed-source coding agent
Signed-off-by: dennev <dennev13@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67292
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
urlToHttpOptions() built its result with `__proto__: null` ahead of a
spread, which makes V8 create the object in dictionary mode. Every
http.request() and https.request() called with a string or URL goes
through it, and ClientRequest immediately copies the result, so both
the property stores and the copy took the slow path.
Use `__proto__: kEmptyObject` instead, as ClientRequest already does
for its option copies. The object stays in fast mode and still
inherits nothing.
Signed-off-by: Yaroslav Chuhai <yaroslavchuhai@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67683
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: James M Snell <jasnell@gmail.com>
A read() made while construct() is pending is refused and leaves
needReadable set. After construction, maybeReadMore() does not read
for a non-flowing stream with highWaterMark: 0, so _read() was never
called and consumers such as toArray() or for await waited forever.
Retry the refused read once construction finishes when highWaterMark
is 0.
Fixes: https://github.com/nodejs/node/issues/67668
Assisted-by: AI coding agents
Signed-off-by: Hamza Kargın <hamzakargin@outlook.com>
PR-URL: https://github.com/nodejs/node/pull/67670
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
Convert base64, base64url and hex strings to a Buffer before computing
the chunk length, so the announced length matches the bytes written
even when the input contains characters skipped while decoding.
Assisted-By: OpenAI GPT-5.6 Sol <openai/gpt-5.6-sol>
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
PR-URL: https://github.com/nodejs/node/pull/67615
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>