381 Commits
Author SHA1 Message Date
Donghoon Kang 531d28fc36 util: fix inspecting URL subclass prototypes
Check the URL private field brand before accessing href to avoid
throwing when inspecting URL subclass prototypes.

Assisted-by: Codex:6.1SolHigh
Signed-off-by: HoonDongKang <d159123@naver.com>
PR-URL: https://github.com/nodejs/node/pull/66822
Fixes: https://github.com/nodejs/node/issues/66821
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
2026-10-20 04:54:54 +00:00
Miodrag Obradovic 1ee5d29c75 util: fix inspect indentation of detached DataView
formatExtraProperties() raised ctx.indentationLvl before reading the
property. The getters of a detached DataView throw, so the level was
never lowered again, and the DataView and everything inspected after it
in the same call ended up indented too far. Read the value first.

Signed-off-by: Miodrag Obradovic <mck097@gmail.com>
Assisted-by: a closed-source coding agent
PR-URL: https://github.com/nodejs/node/pull/66421
Refs: https://github.com/nodejs/node/pull/60131
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-10-03 09:50:25 +00:00
agape1225 ed9ad59672 util: show SuppressedError's error/suppressed properties on inspect
util.inspect() (and console.log()) silently dropped a SuppressedError's
`error` and `suppressed` properties, the two pieces of information
needed to actually debug a disposal failure. Both properties are
non-enumerable, so they never showed up without this.

formatError() already special-cases two other non-enumerable
"container" properties for the same reason: Error's `cause` (#41002)
and AggregateError's `errors` (#43646). Handle SuppressedError's
`error` and `suppressed` the same way; nested SuppressedErrors (from
multiple failed disposals) are shown recursively since inspect()
already recurses into any Error-valued property.

Fixes: https://github.com/nodejs/node/issues/66033

Signed-off-by: agape1225 <49804691+agape1225@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/66159
Fixes: https://github.com/nodejs/node/issues/66033
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-09-22 13:27:47 +00:00
James M Snell c081d10d7e util: implement util.throttle
Often closely related to util.debounce use cases, this adds an
implementation of throttle(fn) .. returns a function that limits
the number of concurrent invocations of fn.

Signed-off-by: James M Snell <jasnell@gmail.com>
Assisted-by: Opencode
PR-URL: https://github.com/nodejs/node/pull/65899
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-09-15 02:31:45 +00:00
James M Snell 27cdfbe13b util: implement debounce
I found myself using debounce quite a bit recently while
testing some recent other additions (quic and dtls testing,
perf_hooks improvements, etc). I was using an npm dependency
right up until I realized just how generally useful it is
to actually have it Just There. So, since it was a holiday
and I just felt like it... util.debounce(...)

Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65899
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-09-15 02:31:44 +00:00
Sergey Sannikov 6b28d8870f assert: fix TypeError on deepStrictEqual with null Map key or Set member
deepStrictEqual() and util.isDeepStrictEqual() threw "Cannot read
properties of null (reading 'constructor')" instead of comparing when
a Map key or Set member was null/undefined (or another primitive) and
lined up against object-only keys/members in the other collection with
an equal count. The primitive/null handling was gated behind an
optimization that is skipped when the counts match, letting such keys
reach objectComparisonStart, which dereferences `.constructor`.

Resolve primitive and null keys/members directly in every case.

Signed-off-by: semx <7532921+semx@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/64449
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-09-12 19:30:04 +00:00
Shelley Vohr 48c90fffb7 src: support building with the V8 sandbox
With V8_ENABLE_SANDBOX every ArrayBuffer backing store has to be
allocated inside the sandbox, so memory that Node.js or a library
allocated itself cannot be wrapped and has to be copied in. Several
places already special-cased this, each with its own #ifdef, but a
build with the sandbox enabled still failed to compile
(`kMaxSafeBufferSizeForSandbox`), aborted in `crypto.randomUUID()`
(`SecureBuffer` was UNREACHABLE) and threw from every caller of the
malloc-owning `Buffer::New()` (v8.serialize, string transcoding, IPC,
the public `Buffer::New(isolate, data, length)`), and trace_events,
SEA assets and FFI still wrapped outside memory unconditionally.

Add `AdoptIntoBackingStore()`, which wraps the memory as before in
regular builds and copies it into an isolate-allocated backing store,
running the deleter right away, when the sandbox is enabled, and use it
at all of those sites so the #ifdef lives in one place. The trace
category flag cannot be copied since JS polls it, so under the sandbox
`getCategoryEnabledBuffer()` returns nothing and lib falls back to
`isTraceCategoryEnabled()`; FFI zero-copy views throw
ERR_OPERATION_FAILED there for the same reason.

Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62237
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-09-07 05:10:02 +00:00
Filip Skokan 2d2250529d crypto: add Hybrid KEMs to Web Cryptography
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65759
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-09-05 10:42:52 +00:00
Antoine du Hamel 4cd3d98510 lib: use Float16Array from primordials
PR-URL: https://github.com/nodejs/node/pull/65702
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-09-03 11:48:46 +02:00
René 1c8799df7e 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-08-27 21:15:40 +00:00
Hamid Reza Ghavami f509cf1d08 util: allow single-line format when break length is infinite
Signed-off-by: Hamid Reza Ghavami <hamidr.ghavami@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64238
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2026-08-24 14:31:34 +00:00
Dushyant Singh HadaandCursor 5b316e5402 util: fix OSC 8 hyperlink stripping in stripVTControlCharacters
The bundled ansi-regex OSC pattern used a restrictive URI
character class that failed when URIs contained RFC 3986-valid
characters such as parentheses.

Match OSC sequences generically as ESC ] ... ST, aligned with
ansi-regex v6.2.0.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: dushyant <dushyanthada90@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64319
Fixes: https://github.com/nodejs/node/issues/64313
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-24 03:14:23 +00:00
Richard Gibson a48e33fb6f util: fix formatting of functions returned from getters
Fixes: https://github.com/nodejs/node/issues/64838
Signed-off-by: Richard Gibson <richard.gibson@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64839
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-08-22 05:07:59 +00:00
Ayoub Mabrouk cc60845420 util: use more primordials in comparisons.js
PR-URL: https://github.com/nodejs/node/pull/61198
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-08-17 10:44:15 +02:00
avivkeller 4a5eb1cf73 repl: add basic syntax highlighting
Signed-off-by: avivkeller <me@aviv.sh>
PR-URL: https://github.com/nodejs/node/pull/64591
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-07-25 23:56:46 -07:00
Chengzhong Wu 5022b94fb5 lib: add perfetto support
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net>
PR-URL: https://github.com/nodejs/node/pull/64565
Refs: https://github.com/nodejs/diagnostics/issues/654
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ryuhei Shima <shimaryuhei@gmail.com>
2026-07-24 14:00:18 +00:00
Paul Bouchon 9df0e9b4d4 assert,util: fix TypeError on Maps with null keys
`assert.deepStrictEqual`, `assert.notDeepStrictEqual`, and
`util.isDeepStrictEqual` threw a `TypeError` instead of returning a
result when one Map had a `null` key with an object value, the other
had an object key with a deeply-equal value but no `null` key, and
both maps were the same size.

In that case `mapObjectEquiv` skipped its primitive and `null` key
handling, which was gated on `array.length !== a.size`, and passed
the `null` key (which is `typeof 'object'`) to the object comparator.
That comparator reads `key.constructor` without a null guard, so it
threw. Handle primitive and `null` keys unconditionally, resolving
them directly against the other map.

Fixes: https://github.com/nodejs/node/issues/64433
Signed-off-by: Paul Bouchon <mail@bitpshr.net>
PR-URL: https://github.com/nodejs/node/pull/64441
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-07-18 16:38:07 +00:00
Antoine du Hamel 5520388f3b lib: use assignFunctionName util where it makes sense
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64515
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-07-17 11:00:54 +00:00
Livia Medeirosandlouiellan 727e2bce8e lib,tools: add node-core/func-name-matching lint rule
And rename functions accordingly.

Signed-off-by: LiviaMedeiros <livia@cirno.name>
Co-authored-by: louiellan <louie.lou.llaneta@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/57901
Refs: https://github.com/nodejs/node/issues/57899
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-07-14 15:30:56 +02:00
Ijtihed Kilani ff58f43f45 util: fix OOM in inspect color stack formatting
Signed-off-by: Ijtihed Kilani <ijtihedk@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64022
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-06-23 19:21:47 +00:00
Daijiro Wachi 5ee27e3f24 util: fix scientific notation formatting
Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63823
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-06-16 02:30:40 +00:00
Daijiro Wachi 3ad2463848 util: fix -0 formatting when numericSeparator is enabled
Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63815
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-06-15 17:55:40 +09:00
Filip Skokan b3ae59d7c6 crypto: harden KeyObject internal slots
Move KeyObject type and handle storage behind NativeKeyObject and
expose it to JS through a module-private slot reader, mirroring the
CryptoKey hardening. Cache the native slot tuple in a private field
and lazily derive secret and asymmetric metadata from the cached
KeyObjectHandle.

Update internal crypto, QUIC, and comparison callers to use private
helpers instead of public KeyObject accessors. Keep getKeyObjectSlots
restricted to internal/crypto/keys with an ESLint guard.

Add regression coverage for brand checks, hidden slots, clone and
transfer behavior, own-property reflection, and post-clone crypto
operations. Extend the CryptoKey brand test to assert getSlots is not
reachable through the public constructor or prototype chain.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63111
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2026-05-08 07:10:03 +00:00
Filip Skokan 25f80fb764 src: decouple KeyObject and CryptoKey and move CryptoKey to src
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62924
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-05-04 00:09:07 +02:00
René 1bc6394601 lib: use js-only implementation of isDataView()
PR-URL: https://github.com/nodejs/node/pull/62780
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-04-18 20:04:06 +00:00
Ruben Bridgewater 8db9d43c45 assert,util: fix stale nested cycle memo entries
Temporary nested cycle-tracking entries could remain in the memory set
after a successful comparison. If a later sibling comparison reused one
of those objects, deepStrictEqual could incorrectly fail for equivalent
structures.
This cleans up the temporary nested entries after the nested
comparison returns.

Fixes: https://github.com/nodejs/node/issues/62422
PR-URL: https://github.com/nodejs/node/pull/62509
Fixes: https://github.com/nodejs/node/issues/62422
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-04-09 16:48:25 +00:00
Hiroki Osame febcecdaaf util: add fast path to stripVTControlCharacters
PR-URL: https://github.com/nodejs/node/pull/61833
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-02-24 19:30:35 +00:00
Ruben Bridgewater 27a7bbc624 assert: fix loose deepEqual arrays with undefined and null failing
The comparison has to accept these as identical.

Fixes: https://github.com/nodejs/node/issues/61583
PR-URL: https://github.com/nodejs/node/pull/61587
Reviewed-By: Jithil P Ponnan <jithil@outlook.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2026-02-01 13:00:17 +00:00
Ruben Bridgewater 955d347884 assert,util: fix deep comparison for sets and maps with mixed types
When comparing a Set or a Map and they contain primitives as keys
as well as objects, the primitives would always be skipped. That
is not correct, since that may only be skipped in case all keys
are objects.

Fixes: https://github.com/nodejs/node/issues/61386
PR-URL: https://github.com/nodejs/node/pull/61388
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2026-01-17 01:12:45 +00:00
Ruben Bridgewater 5c8ce910bd assert,util: improve comparison performance
This makes sure that the toStringTag symbol is used, if available
instead of calculating the toString() value each time, if not
needed (the type checks make a brand check, so there is no need to
check the toStringTag, if non is defined on the object).

PR-URL: https://github.com/nodejs/node/pull/61176
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2025-12-29 16:50:44 +00:00
Ruben Bridgewater 9120924de1 util: fix nested proxy inspection
Fixes: https://github.com/nodejs/node/issues/61061
PR-URL: https://github.com/nodejs/node/pull/61077
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2025-12-22 22:22:04 +00:00
Ruben Bridgewater fc1d6d6b4c assert,util: fix deep comparing invalid dates skipping properties
The property comparison of invalid dates regressed when starting
to handle invalid dates as being equal.

PR-URL: https://github.com/nodejs/node/pull/61076
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-12-22 19:30:35 +00:00
Ruben Bridgewater a968e4e672 assert,util: improve deep comparison performance
PR-URL: https://github.com/nodejs/node/pull/61076
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-12-22 19:30:34 +00:00
Ruben Bridgewater 26b7fd2009 util: limit inspect to only show own properties
`Error`'s `cause` and `errors` properties would be visible even if these
were not own properties. This is changed to align with all other
parts of the `inspect` handling.

Fixes: https://github.com/nodejs/node/issues/60717
PR-URL: https://github.com/nodejs/node/pull/61032
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-12-22 14:06:14 +01:00
Ruben Bridgewater dc97b507d0 util: mark proxied objects as such when inspecting them
Fixes: https://github.com/nodejs/node/issues/60964
PR-URL: https://github.com/nodejs/node/pull/61029
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2025-12-20 17:02:17 +00:00
azadgupta1 060deae99b util: fix parseArgs skipping positional arg with --eval and --print
PR-URL: https://github.com/nodejs/node/pull/60814
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Ilyas Shabi <ilyasshabi94@gmail.com>
2025-12-11 01:09:02 +00:00
Yves M. ca5956cb7a util: safely inspect getter errors whose message throws
PR-URL: https://github.com/nodejs/node/pull/60684
Fixes: https://github.com/nodejs/node/issues/60683
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-11-27 11:06:24 +00:00
Ge Gao fbef1cf438 util: fix stylize of special properties in inspect
Previously, formatExtraProperties applied ctx.stylize to the entire
'[key]: value' string. This caused the colon and space to be styled,
making the output inconsistent with normal object properties.

Now, only the key itself is stylized, and the colon and space remain
unstyled, aligning with the formatting of regular properties.

Refs: https://github.com/nodejs/node/pull/60131
PR-URL: https://github.com/nodejs/node/pull/60479
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-10-31 08:33:38 +00:00
Antoine du Hamel 2fb82c8c28 util: use more defensive code when inspecting error objects
PR-URL: https://github.com/nodejs/node/pull/60139
Fixes: https://github.com/nodejs/node/issues/60107
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-10-20 18:14:39 +00:00
Ruben Bridgewater 70e7c1511f util: mark special properties when inspecting them
This makes sure special properties (such as a byteLength, buffer,
and more) are marked that they are not regular properties. They
are mostly getters, that just seemed even more of a breaking change.
Thus, they just use square brackets for now.

On top of that, it makes inspecting detached DataViews robust.
Inspecting those failed so far.

PR-URL: https://github.com/nodejs/node/pull/60131
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-10-18 21:29:35 +02:00
Ruben Bridgewater c2536adc28 console,util: improve array inspection performance
There is no need to do the own property check, since the descriptor
is needed right afterwards anyway.

PR-URL: https://github.com/nodejs/node/pull/60037
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2025-09-30 15:32:40 +02:00
Miguel Marcondes Filho aa6838c252 lib: update inspect output format for subclasses
PR-URL: https://github.com/nodejs/node/pull/59687
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2025-09-21 06:28:45 +00:00
Miguel Marcondes Filho 4ed9d21880 lib: update isDeepStrictEqual to support options
PR-URL: https://github.com/nodejs/node/pull/59762
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2025-09-14 00:39:49 +00:00
Ruben Bridgewater 60c1fbcf65 util: inspect objects with throwing Symbol.toStringTag
`util.inspect()` should handle all kinds of input, even if it is
not well defined. Throwing is something that is meant to be worked
around in all known cases. This fixes issues inspecting objects
where accessing the Symbol.toStringTag would cause an error. The
symbol is just ignored in that case.

Refs: https://github.com/nodejs/node/issues/55539
Refs: https://github.com/nodejs/node/pull/55544
PR-URL: https://github.com/nodejs/node/pull/59860
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-09-14 00:07:06 +00:00
Ruben Bridgewater 0319ba51d8 util: fix debuglog.enabled not being present with callback logger
The method returned by the callback is missing the .enabled property.
This is added in a consistent way that it also verifies that it's a
getter.

Fixes: https://github.com/nodejs/node/issues/56676
PR-URL: https://github.com/nodejs/node/pull/59858
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-09-14 00:06:57 +00:00
sangwook 670d7ab7f2 util: fix numericSeparator with negative fractional numbers
Fix util.inspect() formatting bug where negative fractional numbers
between -1 and 0 lost their minus sign when numericSeparator was true.
Fixed formatNumber function to preserve sign by using original string
representation. Also corrected test expectations for scientific notation
to not apply numeric separators.
Fixes: https://github.com/nodejs/node/issues/59376

PR-URL: https://github.com/nodejs/node/pull/59379
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-09-08 20:10:50 +00:00
Ruben Bridgewater 0f58a3d0cb util: hide duplicated stack frames when using util.inspect
Long stack traces often have duplicated stack frames from recursive
calls. These make it difficult to identify important parts of the
stack. This hides the duplicated ones and notifies the user which
lines were hidden.

PR-URL: https://github.com/nodejs/node/pull/59447
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2025-09-05 17:15:12 +00:00
Ruben Bridgewater fdef0725de util,console: colorize regexp groups, character classes, etc
This adds a parser to parse the regular expression and to highlight
different parts of a regular expression in case colors are active.

It is a one time pass algorithm and should therefore not cause too
much overhead during parsing.

As side effect, it is now possible to create individual styles to
colorize inspected values values as a user likes. This might for
example be expanded to numbers with numeric separators, highlighting
the separators or decimal points different.

It would in theory also be possible to return a changed string.
That is however not the intention for this API as it is only
triggered in case colors are active.

PR-URL: https://github.com/nodejs/node/pull/59710
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
2025-09-05 14:29:21 +00:00
Filip Skokan 9d744b5b63 crypto: use CryptoKey internal slots in Web Cryptography
PR-URL: https://github.com/nodejs/node/pull/59538
Fixes: https://github.com/nodejs/node/issues/59535
Fixes: https://github.com/nodejs/node/issues/59534
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2025-08-21 14:14:57 +00:00
Ruben Bridgewater 7c9fbc15bc assert,util: fail promise comparison in deep equal checks
It is impossible to look into the content of a promise and its
state. This aligns the comparison with WeakMaps and WeakSets.
Only reference equal promises will pass the check in the future.

Fixes https://github.com/nodejs/node/issues/55198

PR-URL: https://github.com/nodejs/node/pull/59448
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2025-08-19 10:22:35 +00:00