Commit Graph
100 Commits
Author SHA1 Message Date
Joyee Cheung 29ca67351d build: add manually-dispatched stress-test workflow
Add a GitHub action workflow that can be manually dispatched to
stress-run tests on a PR/branch to verify flakiness.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64118
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
2026-07-01 10:45:14 +00:00
Joyee Cheung fd3419178e http: document and validate options.path when it's in absolute-form
When `options.path` passed to `http.request()` contains an absolute
URL, `http.request` has been sending it directly as the request target
in the HTTP 1.1 message. If the receiving server is a proxy,
the proxy server typically forwards the request to the destination
specified in the request target and ignores the Host header.
This means eventually the request can be forwarded to a destination
that is not consistent with `options.host`, depending on how the
receiving server behaves. Mimatched Host header and request target
also violates RFC 9112 Section 3.2, which we have been entirely
leaving to the users to verify.

This patch documents this behavior and warns that the user needs
to ensure the `path`, `option` and `headers` conform to the RFC.
If the receiving server is known to be a proxy server because
the request is routed by Node.js' built-in HTTP proxy support,
we now do a best-effort check to verify that the authority in
`options.path` (if absolute), Host headers and `options.host`
agree at request construction time. Node.js will give up on the
require target rewriting and throw an error when they don't match
at request construction.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64108
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
2026-07-01 10:44:52 +00:00
Joyee Cheung 457fa67062 doc: add guide and answers to FAQs for first-time contributors
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63685
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-06-30 13:07:26 +00:00
Joyee Cheung 6afb49cbc2 meta: update status of past strategic initiatives
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63480
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ruy Adorno <ruy@vlt.sh>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-06-29 13:56:30 +00:00
Joyee Cheung 62a3b1b137 build: pin envinfo versions in github actions
Currently they all run `npx envinfo` without pinning the version.
This can be a supply-chain risk.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/64117
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-06-26 19:47:24 +00:00
Joyee Cheung 61e70cc2be test,debugger: add test for type stripping in debugger probe mode
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63748
Refs: https://github.com/nodejs/node/issues/63646
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-06-19 09:26:48 +00:00
Joyee Cheung 8c4ec8a674 debugger: add --max-hit option to probe mode
This option provides a new way of terminating the probing by
specifying a limit for the per-probe hit evaluation. When any
probe reaches the limit, the session removes the V8 breakpoints
and finishes with a `completed` terminal event rather than waiting
for the target to exit or timeout. This would be useful when we
provide a way to attach to and probe a running process in the future.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63704
Refs: https://github.com/nodejs/node/issues/63646
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-06-13 20:50:15 +00:00
Joyee Cheung 4219808375 module: use file: URL as sourceURL for type-stripped CommonJS
The CommonJS loader was passing the bare filesystem path as the
`//# sourceURL` comment of type-stripped TypeScript, this leads to
two problems:

1. It reports hasSourceURL = false if the path contains any
   whitespaces as this breaks V8's magic comment parser.
2. The inspector would incorrectly report a file path verbatim as
  the script's URL.

Pass the module's file: URL as the sourceURL so the reported URL
is consistent across loaders and won't lead to an issue in
inspector clients that actually except a real URL for the
scripts.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63705
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-06-04 12:25:20 +00:00
Joyee Cheung 0401a2d083 src: fix external reference registration for new CFunction lifetime
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/7828135
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63679
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-06-02 14:33:56 +00:00
Joyee Cheung f30139e3b9 debugger: add more logs to probe mode
Add more log points in the probe mode and enable the debuglog
int the probe mode tests.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63663
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
2026-06-01 20:36:47 +00:00
Joyee Cheung 80e5174567 doc: remove duplicated sentences in large-pull-requests.md
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63650
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2026-05-30 16:20:00 +00:00
Joyee Cheung d85421229c module: load ESM helpers eagerly in the snapshot
Since the ESM loader is captured in the snapshot now, there's
no need to lazy load the helpers. Load them eagerly to capture
them into the snapshot. This also reduces the noise coming out
of --print-bytecode since we no longer compile the helper
functions at run time.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63550
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2026-05-28 14:22:50 +00:00
Joyee Cheung 221ffc08ad test: deflake test-debugger-probe-timeout
On slow machines in the CI, the 200ms timeout may fire before
the probed process finishes evaluation. Increase the timeout
to common.platformTimeout(1000) to accomondate.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63547
Refs: https://github.com/nodejs/reliability/blob/main/reports/2026-05-24.md
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-05-27 06:46:17 +00:00
Joyee Cheung 460c35085f debugger,test: deflake resume failure test and add debug logs
On slow CI, the outer Debugger.resume can be picked up in the
same drain pass as the Debugger.evaluateOnCallFrame, while V8
still considers the context paused. In this case both resume
calls may succeed and the process can continue running from
the setInterval until the timeout. Accept both probe failure
and timeout as valid to accommodate this flakiness.

This patch also adds more debug logs to the probe mode to
show more information in case it flakes again in the CI

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63524
Fixes: https://github.com/nodejs/node/issues/63505
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-05-26 10:20:15 +00:00
Joyee Cheung e2ad744e5f test: remove test-node-output-v8-warning
asm.js validation is deprecated and disabled by default in V8,
so there's no longer a stable user-reachable trigger for
`v8::Isolate::kMessageWarning`. Remove the test.

Refs: https://chromium-review.googlesource.com/c/v8/v8/+/7832184

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63469
Fixes: https://github.com/nodejs/node-v8/issues/310
Refs: https://issues.chromium.org/issues/510487707
Refs: https://github.com/nodejs/node/pull/24365
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/7832184
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-05-25 21:52:00 +00:00
Joyee Cheung 3553a34c2c debugger: surface inspector failures in probe mode
This addresses a few TODOs left from the initial implementation
around the error handling when the inspector session fails
mid-probe - for example because a probe expression terminates
the target, severs the inspector connection, or hangs the
evaluation. Before this patch, these failures would cause the
probe report to silently miss hits or hit the session timeout.
A consumer of these reports could not tell whether the
recorded hits were reliable or a partial trace cut short
by an inspector-side failure.

This patch surfaces those cases as a new `probe_failure` terminal
`error` event on the report, with best-effort attribution to the
implicated probe via `error.probe` and additional context on
`error.details`. Together with `probe_timeout`, it marks the
report as best-effort, and the probing process exits 1 in both
cases. `probe_target_exit` and clean `completed`/`miss` reports
continue to exit 0 because the recorded hits in those cases remain
ground truth, so tooling can use the exit code as a quick
trustworthiness signal. `error.message` now also contains
actionable recovery hints whereever possible.

The per-hit `error` is reshaped to `{ message, details? }`
so that the per-hit and terminal errors share a top-level shape.
Both fields are informative-only, only their top-level type is stable.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63437
Refs: https://github.com/nodejs/node/pull/62713
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Jan Martin <jan.krems@gmail.com>
2026-05-22 12:04:13 +00:00
Joyee Cheung 61d66c32dd test: unskip snapshot reproducibility test
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63307
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Stewart X Addison <sxa@redhat.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-05-21 11:06:29 +02:00
Joyee Cheung ee11c35a3e debugger: disambiguate probe location binding
In probe mode, `--probe utils.js:10` can match multiple scripts
(e.g. `src/utils.js` and `lib/utils.js`) because the matcher uses
a path-separator-anchored URL suffix (similar to how e.g. gdb/lldb
behaves). Previously the report echoed only the user's request in
hit events, so a user seeing two hits at `utils.js:10` could not
tell which script each hit came from. In addition, previously
when the column was omitted we bound to 1 which was technically
different from how CDP binds omitted columns (to the first
executable column on the line).

This patch clarifies the semantics by tracking the scripts via
`Debugger.scriptParsed`, as recommended in the CDP docs, and
reports the actual execution location as `results[i].location`.
The same shape can be reused in the future for source maps or
additional events in attach mode.

This bumps the schema version because `target` is now
`{ suffix, line, column? }` instead of a positional array for
clarity. We picked `suffix` as the field name in case we
introduce other matching modes in the future. `column` is
omitted when the user did not supply one, and the actual
resolved column is reported in the hit event instead.

This patch also adds more tests for column-specific bindings,
multi-location resolution via require(cjs), and late script
binding via dynamic import(cjs) and require(esm).

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63286
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-05-15 16:59:19 +00:00
Joyee Cheung 78bbee385b debugger: add --help to node inspect and improve docs
- Add `--help` / `-h` to `node inspect` covering both interactive and
  non-interactive probe modes. The help text is printed when
  `--help`/`-h` appears before any positional argument to avoid
  hijacking `--help` passed to a child script.
- Improve the documentation of probe mode and add examples, explain
  same-location probe coalescing, TDZ caveat for let/const bindings,
  basename matching and exit code behavior. Also move it to a
  section parallel to interactive mode. Remove recommendation of
  evaluating structured expressions as that is prone to missing
  info in JSON mode.

Drive-by: When probe mode exits due to invalid arguments, exit with
`kInvalidCommandLineArgument` (9) instead of `kGenericUserError` (1).

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63201
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Aviv Keller <me@aviv.sh>
2026-05-11 21:54:19 +00:00
Joyee Cheung 4f44c6f5fe module: fix sync hook short-circuit in require() in imported CJS
- For imported CJS, if it's not customized by asynchronous hooks,
  make sure it won't use the quirky re-invented require in all
  cases.
- When the imported CJS module is customized by synchronous hooks,
  in the synthetic module evalutation step, avoid calling the
  respective default step again.
- Make the branching of loadCJSModuleWithModuleLoad() and
  loadCJSModuleWithSpecialRequire() more explicit, and fold
  the tentative fs read in the 'commonjs' translator into the
  share createCJSModuleWrap() helper instead of checking it
  twice in the same path.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62920
Fixes: https://github.com/nodejs/node/issues/63060
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
2026-05-07 14:44:56 +00:00
Joyee Cheung 6a949577ee debugger: move ProbeInspectorSession and helpers to separate files
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/63013
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Aditi Singh <aditisingh1400@gmail.com>
2026-05-01 13:44:02 +00:00
Joyee Cheung 4f3e6a433a build: enable V8_VERIFY_WRITE_BARRIERS in debug build
PR-URL: https://github.com/nodejs/node/pull/61898
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-04-24 18:01:36 +02:00
Joyee Cheung fff9a8aa03 build,test: test array index hash collision
This enables v8_enable_seeded_array_index_hash and add a test for it.

deps: V8: backport 0a8b1cdcc8b2

Original commit message:

    implement rapidhash secret generation

    Bug: 409717082
    Change-Id: I471f33d66de32002f744aeba534c1d34f71e27d2
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6733490
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: snek <snek@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#101499}

deps: V8: backport 185f0fe09b72

Original commit message:

    [numbers] Refactor HashSeed as a lightweight view over ByteArray

    Instead of copying the seed and secrets into a struct with value
    fields, HashSeed now stores a pointer pointing either into the
    read-only ByteArray, or the static default seed for off-heap
    HashSeed::Default() calls. The underlying storage is always
    8-byte aligned so we can cast it directly into a struct.

    Change-Id: I5896a7f2ae24296eb4c80b757a5d90ac70a34866
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7609720
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#105531}

deps: V8: backport 1361b2a49d02

Original commit message:

    [strings] improve array index hash distribution

    Previously, the hashes stored in a Name's raw_hash_field for decimal
    numeric strings (potential array indices) consist of the literal
    integer value along with the length of the string. This means
    consecutive numeric strings can have consecutive hash values, which
    can lead to O(n^2) probing for insertion in the worst case when e.g.
    a non-numeric string happen to land in the these buckets.

    This patch adds a build-time flag v8_enable_seeded_array_index_hash
    that scrambles the 24-bit array-index value stored in a Name's
    raw_hash_field to improve the distribution.

    x ^= x >> kShift; x = (x * m1) & kMask;    // round 1
    x ^= x >> kShift; x = (x * m2) & kMask;    // round 2
    x ^= x >> kShift;                          // finalize

    To decode, apply the same steps with the modular inverses of m1
    and m2 in reverse order.

    x ^= x >> kShift; x = (x * m2_inv) & kMask;    // round 1
    x ^= x >> kShift; x = (x * m1_inv) & kMask;    // round 2
    x ^= x >> kShift;                              // finalize

    where kShift = kArrayIndexValueBits / 2, kMask = kArrayIndexValueMask,
    m1, m2 (both odd) are the lower bits of the rapidhash secrets, m1_inv,
    m2_inv (modular inverses) are precomputed modular inverse of m1 and m2.
    The pre-computed values are appended to the hash_seed ByteArray in
    ReadOnlyRoots and accessed in generated code to reduce overhead.
    In call sites that don't already have access to the seeds, we read them
    from the current isolate group/isolate's read only roots.

    To consolidate the code that encode/decode these hashes, this patch
    adds MakeArrayIndexHash/DecodeArrayIndexFromHashField in C++ and CSA
    that perform seeding/unseeding if enabled, and updates places where
    encoding/decoding of array index is needed to use them.

    Bug: 477515021
    Change-Id: I350afe511951a54c4378396538152cc56565fd55
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7564330
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#105596}

deps: V8: cherry-pick aac14dd95e5b

Original commit message:

    [string] add 3rd round to seeded array index hash

    Since we already have 3 derived secrets, and arithmetics are
    relatively cheap, add a 3rd round to the xorshift-multiply
    seeding scheme. This brings the bias from ~3.4 to ~0.4.

    Bug: 477515021
    Change-Id: I1ef48954bcee8768d8c90db06ac8adb02f06cebf
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7655117
    Reviewed-by: Chengzhong Wu <cwu631@bloomberg.net>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#105824}

PR-URL: https://github.com/nodejs-private/node-private/pull/834
CVE-ID: CVE-2026-21717

deps: V8: backport 185f0fe09b72

Original commit message:

    [numbers] Refactor HashSeed as a lightweight view over ByteArray

    Instead of copying the seed and secrets into a struct with value
    fields, HashSeed now stores a pointer pointing either into the
    read-only ByteArray, or the static default seed for off-heap
    HashSeed::Default() calls. The underlying storage is always
    8-byte aligned so we can cast it directly into a struct.

    Change-Id: I5896a7f2ae24296eb4c80b757a5d90ac70a34866
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7609720
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#105531}

deps: V8: backport 1361b2a49d02

Original commit message:

    [strings] improve array index hash distribution

    Previously, the hashes stored in a Name's raw_hash_field for decimal
    numeric strings (potential array indices) consist of the literal
    integer value along with the length of the string. This means
    consecutive numeric strings can have consecutive hash values, which
    can lead to O(n^2) probing for insertion in the worst case when e.g.
    a non-numeric string happen to land in the these buckets.

    This patch adds a build-time flag v8_enable_seeded_array_index_hash that
    scrambles the 24-bit array-index value stored in a Name's raw_hash_field
    to improve the distribution.

    x ^= x >> kShift; x = (x * m1) & kMask;    // round 1
    x ^= x >> kShift; x = (x * m2) & kMask;    // round 2
    x ^= x >> kShift;                          // finalize

    To decode, apply the same steps with the modular inverses of m1 and m2
    in reverse order.

    x ^= x >> kShift; x = (x * m2_inv) & kMask;    // round 1
    x ^= x >> kShift; x = (x * m1_inv) & kMask;    // round 2
    x ^= x >> kShift;                              // finalize

    where kShift = kArrayIndexValueBits / 2, kMask = kArrayIndexValueMask,
    m1, m2 (both odd) are the lower bits of the rapidhash secrets, m1_inv,
    m2_inv (modular inverses) are precomputed modular inverse of m1 and m2.
    The pre-computed values are appended to the hash_seed ByteArray in
    ReadOnlyRoots and accessed in generated code to reduce overhead.
    In call sites that don't already have access to the seeds, we read them
    from the current isolate group/isolate's read only roots.

    To consolidate the code that encode/decode these hashes, this patch
    adds MakeArrayIndexHash/DecodeArrayIndexFromHashField in C++ and CSA
    that perform seeding/unseeding if enabled, and updates places where
    encoding/decoding of array index is needed to use them.

    Bug: 477515021
    Change-Id: I350afe511951a54c4378396538152cc56565fd55
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7564330
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#105596}

deps: V8: cherry-pick aac14dd95e5b

Original commit message:

    [string] add 3rd round to seeded array index hash

    Since we already have 3 derived secrets, and arithmetics are
    relatively cheap, add a 3rd round to the xorshift-multiply
    seeding scheme. This brings the bias from ~3.4 to ~0.4.

    Bug: 477515021
    Change-Id: I1ef48954bcee8768d8c90db06ac8adb02f06cebf
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7655117
    Reviewed-by: Chengzhong Wu <cwu631@bloomberg.net>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#105824}

Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
Refs: https://hackerone.com/reports/3511792
Refs: https://github.com/v8/v8/commit/aac14dd95e5be0d487eba6bcdaf9cef4f8bd806c
PR-URL: https://github.com/nodejs/node/pull/61898
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-04-24 18:01:34 +02:00
Joyee Cheung 2387042c11 deps: V8: cherry-pick 00f6e834029f
Original commit message:

    [runtime] always sort transition arrays during rehashing

    After rehashing, the arrays are no longer in hash-sorted order.
    In this case, we need to force a re-sort even for small arrays,
    so that subsequent linear searches can find the correct transition
    and avoid inserting duplicates.

    Refs: https://github.com/nodejs/node/pull/61898#issuecomment-4168690640
    Change-Id: Ia813d1fb9d23e08012811d672052d235c0e0bf4d
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7723678
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Reviewed-by: Igor Sheludko <ishell@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#106255}

Refs: https://github.com/v8/v8/commit/00f6e834029f472ac98514b16a61b5393eb591d9
PR-URL: https://github.com/nodejs/node/pull/61898
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-04-24 18:01:33 +02:00
Joyee CheungandJoyee Cheung 13fb819110 deps: V8: backport bef0d9c1bc90
Original commit message:

    [api] Add V8::GetWasmMemoryReservationSizeInBytes()

    When the system does not have enough virtual memory for the wasm
    cage, installing the trap handler would cause any code allocating
    wasm memory to throw. Therefore it's useful for the embedder to
    know when the system doesn't have enough virtual address space
    to allocate enough wasm cages and in that case, skip the
    trap handler installation so that wasm code can at least work
    (even not at the maximal performance).

    Node.js previously has a command line option
    --disable-wasm-trap-handler to fully disable trap-based bound checks,
    this new API would allow it to adapt automatically while keeping the
    optimization in the happy path, since it's not always possible for
    end users to opt-into disabling trap-based bound checks (for example,
    when a VS Code Server is loaded in a remote server for debugging).

    Refs: https://github.com/nodejs/node/pull/62132
    Refs: https://github.com/microsoft/vscode/issues/251777
    Change-Id: I345c076af2b2b47700e5716b49c3133fdf8a0981
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7638233
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Reviewed-by: Clemens Backes <clemensb@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#105702}

Refs: https://github.com/v8/v8/commit/bef0d9c1bc90357ef5e654b25fcb4ef9f74b591c
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
Refs: https://github.com/microsoft/vscode/issues/251777
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/7638233
PR-URL: https://github.com/nodejs/node/pull/61898
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-04-24 18:01:32 +02:00
Joyee CheungandRené d40be95a2b deps: V8: cherry-pick d83f479604c8
Original commit message:

    Fix compilation for older version of libstdc++

    On older versions of libstdc++, cmath didn't expose std::powl.
    Use std::pow instead.

    Co-Authored-By: René <contact.9a5d6388@renegade334.me.uk>
    Refs: https://gcc.gnu.org/pipermail/libstdc++/2023-February/055493.html
    Refs: https://github.com/nodejs/node/pull/61898
    Change-Id: I4587e14525cae68a05eda03c36b0af40759d9b64
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7666244
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Reviewed-by: Jakob Linke <jgruber@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#105884}

Refs: https://github.com/v8/v8/commit/d83f479604c8cf0e74b7e73e795adbd6f86549f2
PR-URL: https://github.com/nodejs/node/pull/61898
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-04-24 18:01:32 +02:00
Joyee Cheung 38d98c3754 deps: V8: cherry-pick edeb0a4fa181
Original commit message:

    Zero-initialize proxy padding

    So that snapshots with proxies can be reproducible.

    Refs: https://github.com/nodejs/node/pull/61898
    Change-Id: I01fac5e18c73cd482a1ae63750dbadf42a12e08a
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7666243
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#105830}

Refs: https://github.com/v8/v8/commit/edeb0a4fa181d2eace3c3d2fa039584dc6ac2ea6
PR-URL: https://github.com/nodejs/node/pull/61898
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-04-24 18:01:32 +02:00
Joyee Cheung 3dc06aef21 test: normalize known inspector crash as completion
This works around a pre-existing inspector issue:
if the debuggee exits too quickly the inspector can
segfault while tearing down. For now normalize the
trailing segfault as completion to keep the CI green
until the upstream bug is fixed, since it only
reproduces on some slow CI machines and is not
what the probe tests care about.

PR-URL: https://github.com/nodejs/node/pull/62851
Refs: https://github.com/nodejs/node/issues/62765
Refs: https://github.com/nodejs/node/issues/58245
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2026-04-23 19:16:00 +00:00
Joyee Cheung 9531947fd6 fs: restore fs patchability in ESM loader
Temporarily restore fs patchability in ESM loader as a workaround
for helping downstream projects that depend on this undocumented
hidden contract transition into using hook proper APIs. This patch
intentionally avoids adding a test and instead adds warning
comments to hopefully steer new code away from depending on it.

PR-URL: https://github.com/nodejs/node/pull/62835
Refs: https://github.com/nodejs/node/issues/62012
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-04-22 22:45:47 +00:00
Joyee CheungandAntoine du Hamel 05d002fc4a build: make test-addons dependency-free
`make test-addons` used to depend on a markdown parser and then
doc-kit to extract C++ addon examples from addons.md by guessing
the file contents based on headings. This is hacky and brittle.
The introduction of doc-kit also means tests intended for verifying
the binary like `make test-only` now need to support doc-building
toolchains e.g. minifier, highlighter, and indirect dependencies
that rely on prebuilt-addon/wasm, which defeats the purpose
and makes it harder to run for experimental platforms.

This patch adds explicit
`<!-- addon-verify-file dir/filename -->` markers in addons.md to
locate extractable code blocks, avoiding fragile heuristics based on
heading text or code block order and eliminating the dependency
with simpler parsing.

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62388
Fixes: https://github.com/nodejs/node/issues/62385
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-04-22 02:20:37 +00:00
Joyee Cheung a79e224eb2 debugger: add edit-free runtime expression probes to node inspect
Add a non-interactive probe mode to `node inspect` for inspecting
runtime values in a run-to-completion application. This allows
users to perform printf-style debugging without having to modify
the application code and clean up afterwards, it also supports
structured output to be consumed by tools.

Probe mode launches the application, sets one or more source
breakpoints, evaluates one expression at each hit, and prints a
single text or JSON report when execution ends.

Interface:

node inspect [--json] [--preview] [--timeout=<ms>] [--port=<port>]
  --probe <file>:<line>[:<col>] --expr <expr> ...
  [--] <script> [args...]

Example:

```js
// cli.js
let maxRSS = 0;
for (let i = 0; i < 2; i++) {
  const { rss } = process.memoryUsage();
  maxRSS = Math.max(maxRSS, rss);
}
```

```
$ node inspect --probe cli.js:5 --expr 'rss' cli.js
Hit 1 at cli.js:5
  rss = 54935552
Hit 2 at cli.js:5
  rss = 55083008
Completed
```

(Prettified JSON to fit in commit message restrictions).

```js
$ node inspect --json --probe cli.js:5 --expr 'rss' cli.js
{"v":1,"probes":[{"expr":"rss","target":["cli.js",5]}],
"results":[
  {"probe":0,"event":"hit","hit":1,
   "result":{"type":"number","value":55443456,
             "description":"55443456"}},
  {"probe":0,"event":"hit","hit":2,
   "result":{"type":"number","value":55574528,
             "description":"55574528"}},
  {"event":"completed"}]}
```

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62713
Reviewed-By: Jan Martin <jan.krems@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-04-19 15:59:10 +00:00
Joyee Cheung f48ac91894 test: use on-disk fixture for test-npm-install
Instead of writing the fixtures on the fly in the test,
put them in the fixtures directory that can be copied into
a temporary directory to reproduce in a debugger.

Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62584
Refs: https://github.com/nodejs/node/pull/61898
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-04-07 01:38:13 +00:00
Joyee Cheung b411f90413 src: do not enable wasm trap handler if there's not enough vmem
PR-URL: https://github.com/nodejs/node/pull/62132
Refs: https://github.com/microsoft/vscode/issues/251777
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/7638233
Reviewed-By: Aditi Singh <aditisingh1400@gmail.com>
2026-04-02 22:41:30 +00:00
Joyee CheungandJoyee Cheung 8ee5b26f86 deps: V8: backport bef0d9c1bc90
Original commit message:

    [api] Add V8::GetWasmMemoryReservationSizeInBytes()

    When the system does not have enough virtual memory for the wasm
    cage, installing the trap handler would cause any code allocating
    wasm memory to throw. Therefore it's useful for the embedder to
    know when the system doesn't have enough virtual address space
    to allocate enough wasm cages and in that case, skip the
    trap handler installation so that wasm code can at least work
    (even not at the maximal performance).

    Node.js previously has a command line option
    --disable-wasm-trap-handler to fully disable trap-based bound checks,
    this new API would allow it to adapt automatically while keeping the
    optimization in the happy path, since it's not always possible for
    end users to opt-into disabling trap-based bound checks (for example,
    when a VS Code Server is loaded in a remote server for debugging).

    Refs: https://github.com/nodejs/node/pull/62132
    Refs: https://github.com/microsoft/vscode/issues/251777
    Change-Id: I345c076af2b2b47700e5716b49c3133fdf8a0981
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7638233
    Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
    Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Reviewed-by: Clemens Backes <clemensb@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#105702}

Refs: https://github.com/v8/v8/commit/bef0d9c1bc90357ef5e654b25fcb4ef9f74b591c
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62132
Refs: https://github.com/microsoft/vscode/issues/251777
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/7638233
Reviewed-By: Aditi Singh <aditisingh1400@gmail.com>
2026-04-02 22:41:30 +00:00
Joyee Cheung 12c2736546 meta: expand memory leak DoS criteria to all DoS
We have dedicated requirements about memory leaks when triaging
DoS. These applies in generall to all types of DoS, and many recent
reports about DoS attack vectors fail to meet them, resulting in
a lot of extra back-and-forth in triaging. Clarify in the threat
model by expanding these requirements to all DoS.

Drive-by: clarify criteria of documented JavaScript behavior is
that they are included in ECMA262. Also use "Node.js application
developer" instead of "user" the refer to the party being
vulnerable to avoid confusion.

PR-URL: https://github.com/nodejs/node/pull/62505
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2026-04-01 12:10:21 +00:00
Joyee Cheung 0d7e4b1d4b build,test: test array index hash collision
This enables v8_enable_seeded_array_index_hash and add a test for it.

Fixes: https://hackerone.com/reports/3511792

deps: V8: backport 0a8b1cdcc8b2

Original commit message:

    implement rapidhash secret generation

    Bug: 409717082
    Change-Id: I471f33d66de32002f744aeba534c1d34f71e27d2
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6733490
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: snek <snek@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#101499}

Refs: https://github.com/v8/v8/commit/0a8b1cdcc8b243c62cf045fa8beb50600e11758a
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>

deps: V8: backport 185f0fe09b72

Original commit message:

    [numbers] Refactor HashSeed as a lightweight view over ByteArray

    Instead of copying the seed and secrets into a struct with value
    fields, HashSeed now stores a pointer pointing either into the
    read-only ByteArray, or the static default seed for off-heap
    HashSeed::Default() calls. The underlying storage is always
    8-byte aligned so we can cast it directly into a struct.

    Change-Id: I5896a7f2ae24296eb4c80b757a5d90ac70a34866
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7609720
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#105531}

Refs: https://github.com/v8/v8/commit/185f0fe09b72fb869fdcf9a89f40ff2295436bca
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>

deps: V8: backport 1361b2a49d02

Original commit message:

    [strings] improve array index hash distribution

    Previously, the hashes stored in a Name's raw_hash_field for decimal
    numeric strings (potential array indices) consist of the literal
    integer value along with the length of the string. This means
    consecutive numeric strings can have consecutive hash values, which
    can lead to O(n^2) probing for insertion in the worst case when e.g.
    a non-numeric string happen to land in the these buckets.

    This patch adds a build-time flag v8_enable_seeded_array_index_hash that
    scrambles the 24-bit array-index value stored in a Name's raw_hash_field
    to improve the distribution.

    x ^= x >> kShift; x = (x * m1) & kMask;    // round 1
    x ^= x >> kShift; x = (x * m2) & kMask;    // round 2
    x ^= x >> kShift;                          // finalize

    To decode, apply the same steps with the modular inverses of m1 and m2
    in reverse order.

    x ^= x >> kShift; x = (x * m2_inv) & kMask;    // round 1
    x ^= x >> kShift; x = (x * m1_inv) & kMask;    // round 2
    x ^= x >> kShift;                              // finalize

    where kShift = kArrayIndexValueBits / 2, kMask = kArrayIndexValueMask,
    m1, m2 (both odd) are the lower bits of the rapidhash secrets, m1_inv,
    m2_inv (modular inverses) are precomputed modular inverse of m1 and m2.
    The pre-computed values are appended to the hash_seed ByteArray in
    ReadOnlyRoots and accessed in generated code to reduce overhead.
    In call sites that don't already have access to the seeds, we read them
    from the current isolate group/isolate's read only roots.

    To consolidate the code that encode/decode these hashes, this patch
    adds MakeArrayIndexHash/DecodeArrayIndexFromHashField in C++ and CSA
    that perform seeding/unseeding if enabled, and updates places where
    encoding/decoding of array index is needed to use them.

    Bug: 477515021
    Change-Id: I350afe511951a54c4378396538152cc56565fd55
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7564330
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#105596}

Refs: https://github.com/v8/v8/commit/1361b2a49d020a718dc5495713eae0fa67d697b9
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>

deps: V8: cherry-pick aac14dd95e5b

Original commit message:

    [string] add 3rd round to seeded array index hash

    Since we already have 3 derived secrets, and arithmetics are
    relatively cheap, add a 3rd round to the xorshift-multiply
    seeding scheme. This brings the bias from ~3.4 to ~0.4.

    Bug: 477515021
    Change-Id: I1ef48954bcee8768d8c90db06ac8adb02f06cebf
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7655117
    Reviewed-by: Chengzhong Wu <cwu631@bloomberg.net>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#105824}

Refs: https://github.com/v8/v8/commit/aac14dd95e5be0d487eba6bcdaf9cef4f8bd806c
PR-URL: https://github.com/nodejs-private/node-private/pull/834
CVE-ID: CVE-2026-21717

deps: V8: backport 185f0fe09b72

Original commit message:

    [numbers] Refactor HashSeed as a lightweight view over ByteArray

    Instead of copying the seed and secrets into a struct with value
    fields, HashSeed now stores a pointer pointing either into the
    read-only ByteArray, or the static default seed for off-heap
    HashSeed::Default() calls. The underlying storage is always
    8-byte aligned so we can cast it directly into a struct.

    Change-Id: I5896a7f2ae24296eb4c80b757a5d90ac70a34866
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7609720
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#105531}

Refs: https://github.com/v8/v8/commit/185f0fe09b72fb869fdcf9a89f40ff2295436bca
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>

deps: V8: backport 1361b2a49d02

Original commit message:

    [strings] improve array index hash distribution

    Previously, the hashes stored in a Name's raw_hash_field for decimal
    numeric strings (potential array indices) consist of the literal
    integer value along with the length of the string. This means
    consecutive numeric strings can have consecutive hash values, which
    can lead to O(n^2) probing for insertion in the worst case when e.g.
    a non-numeric string happen to land in the these buckets.

    This patch adds a build-time flag v8_enable_seeded_array_index_hash that
    scrambles the 24-bit array-index value stored in a Name's raw_hash_field
    to improve the distribution.

    x ^= x >> kShift; x = (x * m1) & kMask;    // round 1
    x ^= x >> kShift; x = (x * m2) & kMask;    // round 2
    x ^= x >> kShift;                          // finalize

    To decode, apply the same steps with the modular inverses of m1 and m2
    in reverse order.

    x ^= x >> kShift; x = (x * m2_inv) & kMask;    // round 1
    x ^= x >> kShift; x = (x * m1_inv) & kMask;    // round 2
    x ^= x >> kShift;                              // finalize

    where kShift = kArrayIndexValueBits / 2, kMask = kArrayIndexValueMask,
    m1, m2 (both odd) are the lower bits of the rapidhash secrets, m1_inv,
    m2_inv (modular inverses) are precomputed modular inverse of m1 and m2.
    The pre-computed values are appended to the hash_seed ByteArray in
    ReadOnlyRoots and accessed in generated code to reduce overhead.
    In call sites that don't already have access to the seeds, we read them
    from the current isolate group/isolate's read only roots.

    To consolidate the code that encode/decode these hashes, this patch
    adds MakeArrayIndexHash/DecodeArrayIndexFromHashField in C++ and CSA
    that perform seeding/unseeding if enabled, and updates places where
    encoding/decoding of array index is needed to use them.

    Bug: 477515021
    Change-Id: I350afe511951a54c4378396538152cc56565fd55
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7564330
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Cr-Commit-Position: refs/heads/main@{#105596}

Refs: https://github.com/v8/v8/commit/1361b2a49d020a718dc5495713eae0fa67d697b9
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>

deps: V8: cherry-pick aac14dd95e5b

Original commit message:

    [string] add 3rd round to seeded array index hash

    Since we already have 3 derived secrets, and arithmetics are
    relatively cheap, add a 3rd round to the xorshift-multiply
    seeding scheme. This brings the bias from ~3.4 to ~0.4.

    Bug: 477515021
    Change-Id: I1ef48954bcee8768d8c90db06ac8adb02f06cebf
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7655117
    Reviewed-by: Chengzhong Wu <cwu631@bloomberg.net>
    Commit-Queue: Joyee Cheung <joyee@igalia.com>
    Reviewed-by: Leszek Swirski <leszeks@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#105824}

Refs: https://github.com/v8/v8/commit/aac14dd95e5be0d487eba6bcdaf9cef4f8bd806c
2026-03-24 19:50:03 -03:00
Joyee Cheung 9ff27fdb01 sea: support code cache for ESM entrypoint in SEA
The initial support for ESM entrypoint in SEA didn't support
code cache. This patch implements that by following a path
similar to how code cache in CJS SEA entrypoint is supported:
at build time we generate the code cache from C++ and put it
into the sea blob, and at runtime we consume it via a special
case in compilation routines - for CJS this was
CompileFunctionForCJSLoader, in the case of SourceTextModule,
it's in Module::New.

PR-URL: https://github.com/nodejs/node/pull/62158
Refs: https://github.com/nodejs/node/pull/61813
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-03-10 22:37:10 +00:00
Joyee Cheung d0798d12ed doc,module: add missing doc for syncHooks.deregister()
PR-URL: https://github.com/nodejs/node/pull/61959
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-03-03 16:33:28 +00:00
Joyee Cheung dd400b9f12 module: run require.resolve through module.registerHooks()
Previously, require.resolve() called Module._resolveFilename() directly,
bypassing any resolve hooks registered via module.registerHooks(). This
patch fixes that.

PR-URL: https://github.com/nodejs/node/pull/62028
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2026-03-02 18:28:25 +00:00
Joyee Cheung 53ac82626c benchmark: add startup benchmark for ESM entrypoint
PR-URL: https://github.com/nodejs/node/pull/61769
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2026-02-19 12:52:25 +00:00
Joyee Cheung ad1078c0a6 lib: reduce cycles in esm loader and load it in snapshot
PR-URL: https://github.com/nodejs/node/pull/61769
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2026-02-19 12:52:24 +00:00
Joyee Cheung 89555a0733 lib: remove top-level getOptionValue() calls in lib/internal/modules
PR-URL: https://github.com/nodejs/node/pull/61769
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2026-02-19 12:52:23 +00:00
Joyee Cheung 72ee837afa test: allow filtering async internal frames in assertSnapshot
PR-URL: https://github.com/nodejs/node/pull/61769
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2026-02-19 12:52:22 +00:00
Joyee Cheung 9cd6630870 build: skip sscache action on non-main branches
To reduce cache thrashing.

PR-URL: https://github.com/nodejs/node/pull/61790
Refs: https://github.com/nodejs/node/issues/61436
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Tierney Cyren <hello@bnb.im>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2026-02-19 09:49:43 +00:00
Joyee Cheung af0d6d4248 sea: support ESM entry point in SEA
This uses the new StartExecutionCallbackWithModule embedder
API to support ESM entrypoint in SEA via a new configuration
field `"mainFormat"`. The behavior currently aligns with the
embedder API and is mostly in sync with the CommonJS entry
point behavior, except that support for code caching and
snapshot is left for follow-ups.

PR-URL: https://github.com/nodejs/node/pull/61813
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2026-02-18 21:03:33 +00:00
Joyee Cheung 551f605ffe build: build with v8 gdbjit support on supported platform
Build it with gdbjit support on supported platforms by default
allows debugging JIT-compiled code in gdb when it's also enabled
at run time (via --gdbjit). Simply building it in should not
incur an overhead if it's not also enabled at run time.

PR-URL: https://github.com/nodejs/node/pull/61010
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-02-09 23:26:50 +00:00
Joyee Cheung 2c8517e3da src: add more checks and clarify docs for external references
To help catch unregistered bindings.

PR-URL: https://github.com/nodejs/node/pull/61719
Refs: https://github.com/nodejs/node/pull/61718
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-02-09 16:16:23 +00:00
Joyee Cheung b864049f02 src: fix cjs_lexer external reference registration
It needs to be added to the list to actually get registered.

PR-URL: https://github.com/nodejs/node/pull/61718
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-02-09 14:21:34 +00:00
Joyee Cheung 911b158d1d src: support import() and import.meta in embedder-run modules
This adds a embedder_module_hdo for identifying embedder-run
modules in the dynamic import handler and import.meta initializer,
and a SourceTextModuleTypes for customizing source text module
compilation in the JS land via compileSourceTextModule().
Also, refactors the existing embedder module compilation code
to reuse the builtin resolution logic.

PR-URL: https://github.com/nodejs/node/pull/61654
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Aditi Singh <aditisingh1400@gmail.com>
2026-02-09 12:31:24 +00:00
Joyee Cheung a879b39778 test: split test-embedding.js and run tests in parallel
Split the tests so that it's easier to isolate and debug issues,
and we can run the test cases in parallel to speed up. Also
add more comments about what they are testing.

PR-URL: https://github.com/nodejs/node/pull/61571
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-02-08 13:18:27 +00:00
Joyee Cheung 3ab9dd86e7 src: consolidate C++ ReadFileSync/WriteFileSync utilities
This patch moves `ReadFileSync` and `WriteFileSync` from
`src/util.cc` to `src/node_file_utils.cc`, consolidates
the implementation to reuse code, and adds a few more
enhancements:

For `ReadFileSync`:

- Use fstat-based pre-allocation to minimize buffer resizing
  and repeated reads for bigger files.
- Handle various potential overflows in size conversions.
- Handle fallback for 0-byte special files.

For `WriteFileSync`:

- Handle potential partial writes for big enough files and
  support non-seekable files (with -1 as offset).
- Handle 0-byte writes correctly.

In both cases, this now avoids hard aborts and return error code
for the caller to handle as much as possible, except
`std::vector<char> ReadFileSync(FILE* fp)` which is part of the
embedder API.

This patch uses the new `ReadFileSync` to address a TODO in
node_sea.bin.cc.

PR-URL: https://github.com/nodejs/node/pull/61662
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2026-02-07 02:38:56 +00:00
Joyee Cheung f4646a7f4b module: do not invoke resolve hooks twice for imported cjs
Previously the resolve hook can be invoked twice from the
synthetic module evaluation step of imported CJS in the extra
module._load() call that's invoked on the resolved full path.
Add an option to avoid it, since the resolution and loading
has already been done before.

PR-URL: https://github.com/nodejs/node/pull/61529
Fixes: https://github.com/nodejs/node/issues/57125
Refs: https://github.com/nodejs/node/issues/55808
Refs: https://github.com/nodejs/node/issues/56241
Reviewed-By: Jacob Smith <jacob@frende.me>
2026-02-02 23:04:23 +00:00
Joyee Cheung 8e41b8d0c2 sea: print error information when fs operations fail
PR-URL: https://github.com/nodejs/node/pull/61581
Refs: https://github.com/nodejs/node/issues/61579
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
2026-02-02 12:43:45 +00:00
Joyee Cheung baba7483fc src: add initial support for ESM in embedder API
This patch extends `LoadEnvironment` to support loading ES modules,
and adds the following new types:

```cpp
enum class ModuleFormat : uint8_t {
  kCommonJS,
  kModule,
};

// Data for specifying an entry point script for LoadEnvironment().
// This class uses an opaque layout to allow future additions without
// breaking ABI. Use the setter methods to configure the entry point.
class ModuleData {
  void set_source(std::string_view source);
  void set_format(ModuleFormat format);
  void set_resource_name(std::string_view name);

  std::string_view source() const;
  ModuleFormat format() const;
  std::string_view resource_name() const;
};

class StartExecutionCallbackInfoWithModule {
  void set_env(Environment* env);
  void set_process_object(v8::Local<v8::Object> process_object);
  void set_native_require(v8::Local<v8::Function> native_require);
  void set_run_module(v8::Local<v8::Function> run_module);
  void set_data(void* data);

  Environment* env();
  v8::Local<v8::Object> process();
  v8::Local<v8::Function> native_require();
  v8::Local<v8::Function> run_module();
  void* data();
};
```

And two new `LoadEnvironment()` overloads:

```cpp
// Run entry point with ModuleData configuration
MaybeLocal<Value> LoadEnvironment(
    Environment* env,
    const ModuleData* entry_point,
    EmbedderPreloadCallback preload = nullptr);

// Callback-based with new StartExecutionCallbackInfoWithModule
MaybeLocal<Value> LoadEnvironment(
    Environment* env,
    StartExecutionCallbackWithModule cb,
    EmbedderPreloadCallback preload = nullptr,
    void* callback_data = nullptr);
```

PR-URL: https://github.com/nodejs/node/pull/61548
Refs: https://github.com/nodejs/node/issues/53565
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Aditi Singh <aditisingh1400@gmail.com>
2026-02-02 12:24:51 +00:00
Joyee Cheung 983fd3fcf7 build,test: add tests for binary linked with shared libnode
This adds tests to ensure the V8 parts (v8, libplatform, cppgc)
in shared libnode works correctly.

PR-URL: https://github.com/nodejs/node/pull/61463
Refs: https://github.com/nodejs/node/pull/61144
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-01-28 15:02:55 +00:00
Joyee Cheung 8c380ded46 async_hooks: add trackPromises option to createHook()
This adds a trackPromises option that allows users to completely opt
out of the promise hooks that are installed whenever an async hook is
added. For those who do not need to track promises, this avoids
the excessive hook invocation and the heavy overhead from it.

This option was previously already implemented internally to skip the
noise from promise hooks when debugging async operations via the
V8 inspector. This patch just exposes it.

PR-URL: https://github.com/nodejs/node/pull/61415
Refs: https://github.com/nodejs/node/pull/57148
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2026-01-28 11:25:24 +00:00
Joyee Cheung 83893bb370 test: skip --build-sea tests on platforms where SEA is flaky
They were missing from the skip pattern due to different naming.

PR-URL: https://github.com/nodejs/node/pull/61504
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-01-26 13:13:57 +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
Joyee Cheung 6eaf1b85ed test: migrate to --build-sea in existing SEA tests
Only leave a smoking test for the postject-based workflow
in test-single-executable-application.js

PR-URL: https://github.com/nodejs/node/pull/61167
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-01-22 23:32:51 +01:00
Joyee Cheung b935a3970b sea: add --build-sea to generate SEA directly with Node.js binary
Instead of relying on a WASM build of postject to perform the
injection, add LIEF as dependency and generate the SEA directly
from core via a new CLI option --build-sea which takes the SEA
config. This simplifies SEA generation for users and makes it
easier to debug/maintain the SEA building process.

PR-URL: https://github.com/nodejs/node/pull/61167
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-01-22 23:32:50 +01:00
Joyee Cheung 320b2d2b49 sea: split sea binary manipulation code
Split the sea binary manipulation code to a seperate file so that
adding more low-level binary manipulation code doesn't clobber the
higher-level code.

PR-URL: https://github.com/nodejs/node/pull/61167
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-01-22 23:32:48 +01:00
Joyee Cheung d82ae9ee5c deps: add LIEF as a dependency
PR-URL: https://github.com/nodejs/node/pull/61167
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-01-22 23:32:47 +01:00
Joyee Cheung 01f335d968 deps: add tools and scripts to pull LIEF as a dependency
PR-URL: https://github.com/nodejs/node/pull/61167
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-01-22 23:32:45 +01:00
Joyee Cheung 20b62ff488 test: use fixture directories for sea tests
Instead of copying and writing files on the fly for SEA tests,
put the fixtures into a directory and copy them into tmpdir
for testing. This allows easier reproduction and debugging
when they do fail - we can just copy the entire fixture directory
and test directly from there.

PR-URL: https://github.com/nodejs/node/pull/61167
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-01-22 23:32:44 +01:00
Joyee Cheung bc9ffc32bd build: update devcontainer.json to use paired nix env
Refs: https://github.com/nodejs/devcontainer/pull/22
PR-URL: https://github.com/nodejs/node/pull/61414
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tierney Cyren <hello@bnb.im>
2026-01-19 22:34:55 +00:00
Joyee Cheung 3da4dce296 test: split test-esm-loader-hooks
Previously whenever one of the test case fails in the CI, it
barely logged anything useful in the CI and it was difficult to
nail down the specific failing case with a local reproduction,
especially when the test fixutre is inline JavaScript. This patch:

- Puts all the inline JavaScript in on-disk fixtures so that
  they can be re-run easily.
- Split the tests into individual files so that it's easier to nail
  down the failure
- Use spawnSyncAndAssert which logs useful information when the child
  process does not behave as expected.
- Rename the tests as module-hooks/test-async-loader-hooks-* because
  they belong to the module hooks test suite and are not esm-specific.

PR-URL: https://github.com/nodejs/node/pull/61374
Refs: https://github.com/nodejs/reliability/blob/main/reports/2026-01-13.md
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2026-01-16 14:30:12 +00:00
Joyee Cheung 9575913f99 build: add embedtest into native suite
Instead of adding a separate command to run the embedtest, since
it's now run by the node binary via tools/test.py and
test/embedding/test-embedding.js, put embedding into the native
suite in test scripts. This helps adding more embedding tests
into the folder and run them automatically without listing them
one by one in the scripts.

PR-URL: https://github.com/nodejs/node/pull/61357
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
2026-01-15 15:05:48 +00:00
Joyee Cheung 77c2b53834 build: expose libplatform symbols in shared libnode
This requires setting BUILDING_V8_PLATFORM_SHARED to expose the
public symbols since we build with hidden visibility by default.

PR-URL: https://github.com/nodejs/node/pull/61144
Fixes: https://github.com/nodejs/node/issues/61102
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
2026-01-05 13:08:06 +00:00
Joyee Cheung 282d30e526 src: dump snapshot source with node:generate_default_snapshot_source
This helps diffing snapshots when the reproducibility gets broken.

PR-URL: https://github.com/nodejs/node/pull/61101
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-01-03 22:39:11 +00:00
Joyee Cheung c837811baf build: add --debug-symbols to build with -g without enabling DCHECKs
This is useful when debugging release builds on Linux without
enabling DCHECKs.

PR-URL: https://github.com/nodejs/node/pull/61100
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-12-23 14:45:21 +00:00
Joyee Cheung 28f468a615 module: fix sync resolve hooks for require with node: prefixes
Previously, when require()-ing builtins with the node: prefix,
the sync resolve hooks were not properly invoked, and load hooks
could not override the builtin's format. This fixes the
handling and enables redirecting prefixed built-ins to on-disk
files and overriding them with other module types via hooks.

PR-URL: https://github.com/nodejs/node/pull/61088
Fixes: https://github.com/nodejs/node/issues/60005
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2025-12-22 14:35:45 +00:00
Joyee Cheung 1a345922e4 doc: add a tip about developer mode on Windows
On Windows, creating symlinks requires Developer Mode to be
enabled or running the command as Administrator. Tests that
rely on creating symlinks may fail with EPERM errors if
symlink creation is not permitted. Add a tip about this
for the docs about running tests on Windows.

PR-URL: https://github.com/nodejs/node/pull/61112
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
2025-12-20 12:28:30 +00:00
Joyee Cheung 4f24aff94a module: preserve URL in the parent created by createRequire()
Previously, createRequire() does not preserve the URL it gets
passed in the mock parent module created, which can be
observable if it's used together with module.registerHooks().
This patch adds preservation of the URL if createRequire()
is invoked with one.

PR-URL: https://github.com/nodejs/node/pull/60974
Fixes: https://github.com/nodejs/node/issues/60973
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2025-12-13 07:36:20 +00:00
Joyee Cheung 28b11396fe doc: mark sync module hooks as release candidate
PR-URL: https://github.com/nodejs/node/pull/60960
Refs: https://github.com/nodejs/node/issues/56241
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2025-12-12 17:12:13 +00:00
Joyee Cheung 7f78002f03 doc: reorganize docs of module customization hooks
This reorganizes the documentation of module customization hooks
to promote the synchronous variant as it has fewer caveats.
Previously the documentation was organized as follows:

To do something:
1. For asynchronous hooks, do this, which may have these caveats
2. For synchronous hooks, do this, which does not have the caveats

To do something else:
1. For asynchronous hooks, do this, which may have these caveats
2. For synchronous hooks, do this, which does not have the caveats

It's now organized as follows:

Synchronous hooks:
To do something, do this.
To do something else, do this.
(No mention that it doesn't have caveats, because users are not supposed
to burden themselves with caveats in the other API that they do not
use).

Asynchronous hooks:
They have these caveats, if they are too complex to deal with, consider
use the synchronous variant.

To do something, do this, which may have these caveats.
To do something, do this, which may have these caveats.

PR-URL: https://github.com/nodejs/node/pull/60960
Refs: https://github.com/nodejs/node/issues/56241
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2025-12-12 17:12:12 +00:00
Joyee Cheung 159f9c203b doc: mark crypto.hash as stable
This API has been stable for the past year and it's used enough
in the wild that we are unlikely to make any breaking changes
without going semver-major. Mark it as stable.

PR-URL: https://github.com/nodejs/node/pull/60994
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2025-12-10 17:11:33 +00:00
Joyee Cheung c0108bfc55 http: add http.setGlobalProxyFromEnv()
This adds an API to dynamically enable built-in proxy support
for all of fetch() and http.request()/https.request(), so
that users do not have to be aware of them all and configure them
one by one.

PR-URL: https://github.com/nodejs/node/pull/60953
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2025-12-10 16:12:28 +00:00
Joyee Cheung 40c57ed1b5 module: mark require(esm) as stable
This has been released to all active LTS release lines and many
popular packages have been shipping ESM-only distributions based
on the existence of this feature on active LTS. The current documented
behaviors are unlikely to change in a breaking manner within a major
release - as everything with the module loaders, there can always be
subtle changes to undocumented surface that can break edge cases that
assume undocumented behaviors, due to Hyrum's law; but the stability
of this feature is now not different than any other stable parts of
the module loader. It's time to mark it as stable.

PR-URL: https://github.com/nodejs/node/pull/60959
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2025-12-08 16:11:50 +00:00
Joyee Cheung 902a2e41c7 cli: add --require-module/--no-require-module
To replace --experimental-require-module and
--no-experimental-require-module. The experimental
ones are left as legacy aliases.

PR-URL: https://github.com/nodejs/node/pull/60959
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2025-12-08 16:11:49 +00:00
Joyee Cheung 1fbe842d64 module: mark module compile cache as stable
The feature set has been stable without any breaking changes
in the past year, and it's been depended enough in the wild
by popular packages that we'll likely need to treat any breakages
as semver-major in the future anyway. The future TODOs are likely
all non-breaking. Potential subtle breakages in implementation
details that should not be relied upon (such as the cache layout)
are explicitly excluded from the contract.

We'll investigate whether it can be enabled by default as a
different topic, which can be potentially semver-major.

PR-URL: https://github.com/nodejs/node/pull/60971
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2025-12-08 15:08:11 +00:00
Joyee Cheung caa0cbf94f v8: mark v8.queryObjects() as stable
This has been used in the tests for leak testing stably for
over a year. The API is modeled after the Chrome DevTools console API
is unlikely to have breaking changes. It's time to mark it as stable.

PR-URL: https://github.com/nodejs/node/pull/60957
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-12-08 14:09:39 +00:00
Joyee Cheung e284d037ce cli: mark --heapsnapshot-near-heap-limit as stable
This has not changed in the past 5 years and has been passing the tests
for 5 years. Mark it as stable.

PR-URL: https://github.com/nodejs/node/pull/60956
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-12-08 14:09:30 +00:00
Joyee Cheung 728f23c938 doc: mark --build-snapshot and --build-snapshot-config as stable
While the support for serialization of built-in modules is likely
to be open-ended, the CLI flags themselves have been very stable.
Mark them as stable and update the documentation about the support
status of built-in module serialization.

PR-URL: https://github.com/nodejs/node/pull/60954
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2025-12-08 14:09:20 +00:00
Joyee Cheung 6432765a9c src: fix off-thread cert loading in bundled cert mode
https://redirect.github.com/nodejs/node/pull/59856 had an typo/mistake
in the skip conditions so that it is skipping when --use-openssl-ca
or --openssl-system-ca-path (configure time) are NOT used, even
though they should be skipped only when those ARE used (which is
not the default for default builds). This change fixes that so
that the perf numbers in that PR is true for the default build.

PR-URL: https://github.com/nodejs/node/pull/60764
Reviewed-By: Aditi Singh <aditisingh1400@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-12-02 09:51:06 +00:00
Joyee Cheung f9f343fb8d src: handle DER decoding errors from system certificates
When decoding certificates from the system store, it's not actually
guaranteed to succeed. In case the system returns a certificate
that cannot be decoded (might be related to SSL implementation issues),
skip them.

PR-URL: https://github.com/nodejs/node/pull/60787
Refs: https://github.com/microsoft/vscode/issues/277064
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Aditi Singh <aditisingh1400@gmail.com>
Reviewed-By: Tim Perry <pimterry@gmail.com>
2025-12-01 07:26:03 +00:00
Joyee Cheung 61cf89cb35 doc,test: add documentation and test on how to use addons in SEA
PR-URL: https://github.com/nodejs/node/pull/59582
Fixes: https://github.com/nodejs/node/issues/60611
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-11-17 04:41:11 +00:00
Joyee Cheung 2243e58e43 deps: use std::map in MSVC STL for EphemeronRememberedSet
PR-URL: https://github.com/nodejs/node/pull/58070
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-11-13 15:09:06 +01:00
Joyee Cheung 04a086a1f4 esm: use wasm version of cjs-module-lexer
The synchronous version has been available since 1.4.0.

PR-URL: https://github.com/nodejs/node/pull/60663
Refs: https://github.com/nodejs/node/issues/59913
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-11-12 18:34:59 +00:00
Joyee Cheung 275215f7bc benchmark: use typescript for import cjs benchmark
The original benchmark uses a not very realistic fixture (it has
a huge try-catch block that would throw on the first line and then
export at the end, hardly representative of real-world code).
Also, it measures the entire import including evaluation, not just
parsing. This updates the name to import-cjs to be more accurate,
and use the typescript.js as the fixture which has been reported
to be slow to import, leading users to use require() to work around
the peformance impact. It splits the measurement into two different
types: parsing CJS for the first time (where the overhead of
loading the lexer makes a difference) and parsing CJS after the
lexer has been loaded.

PR-URL: https://github.com/nodejs/node/pull/60663
Refs: https://github.com/nodejs/node/issues/59913
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-11-12 18:34:59 +00:00
Joyee Cheung ea1a240633 test: split test-runner-run-watch.mjs
This test contains too many independent test cases and as a
result, marking it as flaky on all major platforms means
actual regressions could be covered up, and it's constantly
making the CI orange and requires extra resuming on the
flaked platforms which is still not great. Split it into
individual files so that the actual flake can be identified
out of the monolith.

PR-URL: https://github.com/nodejs/node/pull/60653
Refs: https://github.com/nodejs/node/issues/54534
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-11-11 10:36:52 +00:00
Joyee Cheung 12fad1bd7b src: build v8 tick processor as built-in source text modules
Instead of polyfilling it with vm.SourceTextModule,
use a built-in source text module loader so that we can
also build the code cache for it at build tiem to
embed the code cache for them in the binary.

Drive-by: instead of inferring how to compile a particular
built-in at run time, do the inferring at build time,
so the function-based built-ins can be compiled using
parameters quickly looked up from a static map, and
the builtins that should be compiled as source text
modules are known internally based on extension in
the source code (at run time, the extensions are all
removed).

PR-URL: https://github.com/nodejs/node/pull/60518
Reviewed-By: Aditi Singh <aditisingh1400@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2025-11-11 02:53:13 +00:00
Joyee Cheung 33f982e7ed test: deflake test-perf-hooks-timerify-histogram-sync
The previous busy loop wasn't robust enough in making sure
that the function runs for more than 1 nanosecond - and when it
runs faster than that on a fast machine, it measures to 0 for
nanosecond precision and throws a RangeErorr as histogram.record()
only takes positive values. Update it to use Atomics.wait() to
make sure that the function being measured runs for at least
1 millisecond so that the histogram always records a positive value.

PR-URL: https://github.com/nodejs/node/pull/60639
Fixes: https://github.com/nodejs/node/issues/60638
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-11-10 17:46:46 +00:00
Joyee Cheung bd3a202133 test: apply a delay to watch-mode-kill-signal tests
The test is still flaking on macOS. This might be caused by fs
event coalescing. Apply a delay to reduce the chance of it.
Also, add a bit more logs to show more information.

PR-URL: https://github.com/nodejs/node/pull/60610
Refs: https://github.com/nodejs/reliability/blob/main/reports/2025-11-07.md
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2025-11-10 12:11:05 +01:00
Joyee Cheung d137969789 test: parallelize sea tests when there's enough disk space
The sea tests are only run sequentially to avoid taking too much
disk space. When there is enough disk space, however, it's better
to run them in parallel, as these tests tend to be slow.

PR-URL: https://github.com/nodejs/node/pull/60604
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2025-11-08 16:56:06 +00:00
Joyee Cheung 53ee03868f benchmark: focus on import.meta intialization in import-meta benchmark
Instead of measuring the performance of the entire module
initialization, focus only on the import.meta initialization.

PR-URL: https://github.com/nodejs/node/pull/60603
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2025-11-08 16:33:34 +00:00
Joyee Cheung 1d6a62662c src: move import.meta initializer to native land
When the source text module is compiled without custom callbacks,
instead of calling into JS land from the per-isolate import.meta
initializer and then back to C++ land to set up lazy data
properties, just do the initialization all in C++ land.
Only import.meta.resolve initialization will call back
into JS land to generate a closure that call the cascaded loader
for resolution.

In addition, simplify the loader structure by merging
allowImportMetaResolve into isForAsyncLoaderHookWorker - the two
are essentially equivalent, as import.meta.resolve is only
allowed in a non-loader-hook worker thread's loader.

PR-URL: https://github.com/nodejs/node/pull/60603
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2025-11-08 16:33:34 +00:00
Joyee Cheung 622c3721bf benchmark: add per-suite setup option
This allows us to set up fixtures for the benchmark suite only
once, which can save quite a bit of time when running benchmarks
that require tens of thousands of fixture files or more (e.g.
the module benchmarks).

PR-URL: https://github.com/nodejs/node/pull/60574
Fixes: https://github.com/nodejs/node/issues/58488
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2025-11-07 17:47:43 +00:00
Joyee Cheung 7c85846cd9 test: only show overridden env in child process failures
Previously when the child process helpers are used to print
information about the failed expectations and the env of the
child process was overridden, it printed the entire env object,
which may be too much if the caller does something like
{ env: { ENV: 'var', ...process.env } } (which tend to be always
the case for specifying env because we need to copy the
process.env for dynamic library loading in the CI).
This updates it to only show the env vars that differ from
process.env for a cleaner log in the case of failure.

PR-URL: https://github.com/nodejs/node/pull/60556
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2025-11-07 17:47:33 +00:00
Joyee Cheung 9495906f8b debugger: fix event listener leak in the run command
It should remove both the error and the ready event listeners
attached when either of them fires, instead of removing only
the one whose corresponding event fires, otherwise the other
event listener will always get leaked.

PR-URL: https://github.com/nodejs/node/pull/60464
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-11-07 13:28:03 +00:00
Joyee Cheung b4b1413779 test: split test-perf-hooks-timerify
This test has been flaky in the CI. It squeezes too many independent
test cases into one file, so split it up so that we can mark the
persistent flaky test case and leave the unproblematic ones alone.

PR-URL: https://github.com/nodejs/node/pull/60568
Refs: https://github.com/nodejs/node/issues/54803
Refs: https://github.com/nodejs/reliability/blob/main/reports/2025-11-03.md
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2025-11-05 15:19:04 +00:00