Matteo Collina
384d7a40ce
events: optimize once() and removeListener()
...
Use a closure instead of a bound state object for the once() wrapper,
keep the events object shape in removeListener() by storing undefined
instead of deleting keys or reallocating the object, and outline the
cold unhandled 'error' path from emit() and the max-listeners warning
from _addListener() so both fit within V8 inlining budgets.
ee-once +25%, ee-add-remove +12-22%, ee-listen-unique +7-15%,
streams/pipe +13.9%.
Signed-off-by: Matteo Collina <hello@matteocollina.com >
PR-URL: https://github.com/nodejs/node/pull/64373
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2026-07-13 08:50:08 +00:00
Chengzhong Wu
cff8bfd865
test: unify assertSnapshot stacktrace transform
...
The snapshotted stack frames should hide node internal stack frames so
that general node core development does not need updating the snapshot.
For userland stack frames, they are highly fixture related and any
fixture change should reflect in a change of the snapshot. Additionally,
the line and column number are highly relevant to the correctness of the
snapshot, these should not be redacted. A change in node core that
affects userland stack frames should be alarming and be reflected in the
snapshots.
Features like test runner and source map support both should snapshot
userland stack frames to ensure that userland code locations are
computed correctly.
PR-URL: https://github.com/nodejs/node/pull/61665
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com >
2026-02-11 14:36:49 +00:00
Chengzhong Wu
bdceaa2117
test: unify assertSnapshot common patterns
...
Unifes assertSnapshot common patterns like platform specific path
separators, line ending, line trailing spaces, Node.js version strings,
and pids in warning messages.
PR-URL: https://github.com/nodejs/node/pull/61590
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day >
2026-02-02 23:04:33 +00:00
Joyee Cheung
644ba1f7e6
module: do not wrap module._load when tracing is not enabled
...
This prevents clobbering the stack traces with another internal
frame and removes the unnecessary hoops from step-debugging.
PR-URL: https://github.com/nodejs/node/pull/61479
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2026-01-26 11:20:53 +00:00
Antoine du Hamel
0457bfee2c
test: forbid use of named imports for fixtures
...
PR-URL: https://github.com/nodejs/node/pull/61228
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk >
2026-01-01 23:48:26 +00:00
Gürgün Dayıoğlu
a65421a679
process: preserve AsyncLocalStorage in queueMicrotask only when needed
...
PR-URL: https://github.com/nodejs/node/pull/60913
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2025-12-21 01:12:15 +00:00
Ruben Bridgewater
d3f79aa65d
assert: allow printf-style messages as assertion error
...
Also add functions as allowed message input.
This allows to have leavy message computation to become cheaper.
PR-URL: https://github.com/nodejs/node/pull/58849
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-10-17 20:15:17 +00:00
Gürgün Dayıoğlu
15278252bb
lib: remove redundant destroyHook checks
...
PR-URL: https://github.com/nodejs/node/pull/60120
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2025-10-08 12:11:43 +00:00
Miguel Marcondes Filho
4f5d11e6fb
lib: restructure assert to become a class
...
PR-URL: https://github.com/nodejs/node/pull/58253
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-08-05 14:15:02 +00:00
Antoine du Hamel
caf478b72e
tools: enable linter in test/fixtures/errors
...
PR-URL: https://github.com/nodejs/node/pull/57701
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com >
2025-04-04 15:41:48 +02:00
Colin Ihrig
840f952268
punycode: limit deprecation warning
...
DEP0040 is an extremely annoying warning. Most of the people
seeing it cannot do anything about it. This commit updates the
warning logic to only emit outside of node_modules. This is
similar to other warnings such as the Buffer() constructor
warning.
Ideally, this should be backported to Node 22.
Refs: https://github.com/nodejs/node/pull/47202
PR-URL: https://github.com/nodejs/node/pull/56632
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-01-18 18:01:54 +00:00
Chengzhong Wu
483e3d5e4b
src: fix undefined script name in error source
...
PR-URL: https://github.com/nodejs/node/pull/56502
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-01-09 14:06:31 +00:00
Shelley Vohr
e4f61de14f
test: make snapshot comparison more flexible
...
PR-URL: https://github.com/nodejs/node/pull/54375
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2024-08-16 14:29:22 +00:00
Stephen Belanger
d1229eeca4
lib: rewrite AsyncLocalStorage without async_hooks
...
PR-URL: https://github.com/nodejs/node/pull/48528
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2024-08-02 19:44:20 +00:00
RafaelGSS and Stephen Belanger
fbdfe9399c
lib: add diagnostics_channel events to module loading
...
This commit adds a tracing channel for module loading
through `import()` and `require()`.
Co-Authored-By: Stephen Belanger <admin@stephenbelanger.com >
PR-URL: https://github.com/nodejs/node/pull/44340
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
2024-06-20 21:25:04 -03:00
Vinicius Lourenço
f88386561c
module: print amount of load time of a cjs module
...
PR-URL: https://github.com/nodejs/node/pull/52213
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2024-05-30 16:58:59 +00:00
Aras Abbasi
be8d64ec14
process: improve event-loop
...
PR-URL: https://github.com/nodejs/node/pull/52108
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2024-05-06 20:16:22 +00:00
Aras Abbasi
83e6350b82
errors: improve hideStackFrames
...
PR-URL: https://github.com/nodejs/node/pull/49990
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-11-11 16:25:08 +00:00
Yiyun Lei
853f57239c
test: migrate message error tests from Python to JS
...
Migrate the remaining error tests in the `test/message` folder
from Python to JS.
Fixes: https://github.com/nodejs/node/issues/47707
PR-URL: https://github.com/nodejs/node/pull/49721
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
2023-09-21 22:14:34 +00:00
Geoffrey Booth
a71e3a65bb
test: fix edge snapshot stack traces
...
PR-URL: https://github.com/nodejs/node/pull/49659
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
2023-09-17 20:59:41 +00:00
Geoffrey Booth
f42a103991
esm: require braces for modules code
...
PR-URL: https://github.com/nodejs/node/pull/49657
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2023-09-15 19:18:13 +00:00
Darshan Sen
6cd678965f
sea: add support for V8 bytecode-only caching
...
Refs: https://github.com/nodejs/single-executable/issues/73
Signed-off-by: Darshan Sen <raisinten@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/48191
Fixes: https://github.com/nodejs/single-executable/issues/73
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2023-07-26 10:10:35 +00:00
Yagiz Nizipli
951da5282c
lib: merge cjs and esm package json reader caches
...
PR-URL: https://github.com/nodejs/node/pull/48477
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-06-29 18:45:31 +00:00
RafaelGSS
daaa43ed96
policy: handle mainModule.__proto__ bypass
...
PR-URL: https://github.com/nodejs-private/node-private/pull/416
Fixes: https://hackerone.com/bugs?subject=nodejs&report_id=1877919
Reviewed-By: Rich Trott <rtrott@gmail.com >
CVE-ID: CVE-2023-30581
2023-06-20 17:31:28 -03:00
Moshe Atlow
05693acb15
lib: support FORCE_COLOR for non TTY streams
...
PR-URL: https://github.com/nodejs/node/pull/48034
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2023-05-18 12:36:38 +00:00
Moshe Atlow
b6738c1af0
test: migrate message tests to use assertSnapshot
...
PR-URL: https://github.com/nodejs/node/pull/47498
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2023-04-27 06:41:58 +00:00