GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com (truncated) — Transcribe Chromium Replay-owned inspector Mark+Disallow fences into Node by Domiii · Pull Request #155 · replayio/node

Conversation

@Domiii

@Domiii Domiii commented Sep 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Summary

  • WHY
    • Replay-owned inspector work must run under Mark+Disallow
    • Matches Chromium ownership fencing
    • Independent of any crash investigation
  • Causal chain
    • Connect runs under Mark+Disallow
    • Seeds m_replay_owned / replay_owned_ from AreEventsDisallowed()
    • Owned sites key AutoMaybe* / Mark+Disallow on that seed
  • WHAT
    • Session / inspector / agent / InjectedScript ownership fences
    • Connect + Dispatch + frontend SendMessageToFrontend fences
    • createInjectedScript passes session ownership into InjectedScript
    • IsActive unchanged: any connected channel
    • No ChannelImpl frontend fence: sink-only, matching Chromium

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Domiii
Transcribe Chromium Replay-owned inspector Mark+Disallow / AutoMaybeR…
d25ecd1
…eplayOwned fences into Node.
@Domiii Domiii self-assigned this Sep 23, 2026
@Domiii
Domiii requested review from Andarist, bhackett1024 and markerikson September 23, 2026 11:02
Andarist
Andarist approved these changes Sep 23, 2026
View reviewed changes

@Andarist Andarist left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My agent found some potential discrepanciec when comparing to Chromium:

Only the parts of the patch that touch the embedder differ from Chromium. Every V8 hunk (all 17 files under `deps/v8/src/inspector/`) matches Chromium's `chromium-v8` master site for site, with the same labels and semantics.

The differences, all in `src/`:

1. **`ChannelImpl::sendMessageToFrontend` fence** ([[inspector_agent.cc](https://claude.ai/node/src/inspector_agent.cc)](../../../node/src/inspector_agent.cc)): Chromium has nothing like it. Its `InspectorChannel` is a bare channel, and the only fence is in the `SendMessageToFrontend` sink. In Node, that sink is `RecordReplaySessionDelegate::SendMessageToFrontend`, which the patch already fences. So the `ChannelImpl` branch is redundant, and so are the `isolate_` and `replay_owned_` members and the `replayOwned()` accessor that support it. The branch also carries a dead duplicate `raw_message` conversion.

2. **Connect fence is unconditional** ([[node_process_methods.cc](https://claude.ai/node/src/node_process_methods.cc)](../../../node/src/node_process_methods.cc)): Chromium's `getInspectorSession` wraps `connect()` in Mark+Disallow only when `!IsCommandHandlingEnabledWhenRecording()`. When the recording also handles commands, it creates the session unfenced, so the session isn't Replay-owned. Node has no such mode, so the unconditional fence is correct today. It would need that condition if the mode is ever added.

3. **`Dispatch` fence covers more than in Chromium**: the fence itself matches Chromium's `SendCDPMessage` fence. But Node's `Dispatch` goes through `ChannelImpl`, which also routes `NodeRuntime`, `NodeTracing` and `NodeWorker` commands. So those Node agents also run as Replay code under this fence. Chromium's equivalent fence only ever reaches V8's own dispatcher.

The label strings also differ (`RecordReplaySendCDPMessage` vs `SendCDPMessage`, `RecordReplaySendCDPMessage::Connect` vs `RecordReplayRegisterV8Inspector`). That only affects diagnostics.

With the conclusion that the first item is worth fixing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Domiii reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Domiii @cursoragent
Drop redundant ChannelImpl sendMessageToFrontend Mark+Disallow fence.
9e931bf
RecordReplaySessionDelegate already fences the sink; Chromium has no channel-level equivalent.

Co-authored-by: Cursor <[email protected]>
@Domiii
Domiii merged commit 769783c into master Sep 23, 2026
3 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Domiii
Domiii deleted the dominik/crash-0111-inspector-ownership-transcribe branch September 23, 2026 13:55
bhackett1024 pushed a commit that referenced this pull request Nov 5, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
d8812ea
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
bhackett1024 added a commit that referenced this pull request Nov 5, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
568c156
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist @claude
Track replay-owned inspector sessions
18c0007
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist @claude
Add Node.js record/replay driver integration and API
f3583c2
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist @claude
Track replay-owned inspector sessions
6c79ac9
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist @claude
Add Node.js record/replay driver integration and API
3d9b0a5
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,
#168, #169, #176, #178, #181 and #215.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist @claude
Track replay-owned inspector sessions
67800a5
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist @claude
Add Node.js record/replay driver integration and API
15df7ba
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
f195389
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
c41397f
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
b157f26
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
5119571
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
b48a07f
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
2419347
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,
#168, #169, #176, #178, #181 and #215.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist @claude
Track replay-owned inspector sessions
aa179f1
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist @claude
Add Node.js record/replay driver integration and API
c0459bf
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
cf067ee
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist @claude
Track replay-owned inspector sessions
f0f5877
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
1344673
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
e1e28fe
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
a1092ec
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
4025be3
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
78d8547
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
337ae66
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
039da9a
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

CDP messages from the inspector are accepted as Latin-1: node 26 hands them
over in that encoding, and decoding them as UTF-8 corrupted any message with a
byte above 0x7f.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
918036f
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
d10b59e
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
abba21d
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
4dd9b6f
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
ab99556
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
a7cf652
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
cb105ed
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
57aa4c3
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

CDP messages from the inspector are accepted as Latin-1: node 26 hands them
over in that encoding, and decoding them as UTF-8 corrupted any message with a
byte above 0x7f.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
1e860f6
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
2f53f7f
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

CDP messages from the inspector are accepted as Latin-1: node 26 hands them
over in that encoding, and decoding them as UTF-8 corrupted any message with a
byte above 0x7f.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
811f04d
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
dec52f8
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

CDP messages from the inspector are accepted as Latin-1: node 26 hands them
over in that encoding, and decoding them as UTF-8 corrupted any message with a
byte above 0x7f.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
2ffd15a
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
4e62c2e
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
baf58ce
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
4436a8b
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
9b295e2
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
ff2cade
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 11, 2026
@Domiii @Andarist
Track replay-owned inspector sessions
cf8e26a
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 11, 2026
@bhackett1024 @Andarist
Add Node.js record/replay driver integration and API
5e9c2a5
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

CDP messages from the inspector are accepted as Latin-1: node 26 hands them
over in that encoding, and decoding them as UTF-8 corrupted any message with a
byte above 0x7f.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 11, 2026
@Domiii @Andarist @claude
Track replay-owned inspector sessions
961c7f2
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 11, 2026
@bhackett1024 @Andarist @claude
Add Node.js record/replay driver integration and API
8f615b8
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

CDP messages from the inspector are accepted as Latin-1: node 26 hands them
over in that encoding, and decoding them as UTF-8 corrupted any message with a
byte above 0x7f.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 11, 2026
@Domiii @Andarist @claude
Track replay-owned inspector sessions
ea19603
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 11, 2026
@bhackett1024 @Andarist @claude
Add Node.js record/replay driver integration and API
cac7b47
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

CDP messages from the inspector are accepted as Latin-1: node 26 hands them
over in that encoding, and decoding them as UTF-8 corrupted any message with a
byte above 0x7f.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 12, 2026
@Domiii @Andarist @claude
Track replay-owned inspector sessions
aab9af6
A session created while events are disallowed belongs to the replay
driver rather than to a DevTools frontend. Record that at connect time
and, for owned sessions, run teardown, reset and injected-script
discarding as replay code with events disallowed, so that work cannot
diverge from the recording.

Add src/base/replayio.h with AutoMaybe* helpers, which apply
AutoMarkReplayCode/AutoDisallowEvents only when a condition holds, so
call sites don't have to nest scopes unconditionally.

Transcribe the remaining Chromium Mark+Disallow fences. The session
passes its ownership flag to the InjectedScript it creates for a
context, so wrapObject, discardEvaluateCallbacks,
setCustomObjectFormatterEnabled and the promise handler's
then/catch/promise-collected callbacks fence on it as well, and the
session itself fences dispatchProtocolMessage, releaseObjectGroup,
reportAllContexts and setCustomObjectFormatterEnabled. The runtime,
debugger, console, profiler and heap profiler agents, v8-console and
InspectedContext fence their own entry points the same way. The
channel's sendMessageToFrontend gets no fence: node's
RecordReplaySessionDelegate already fences the sink, and Chromium has
no channel-level equivalent.

V8 11.3 ends V8DebuggerAgentImpl::didPause with
v8::debug::NotifyDebuggerPausedEventSent, which samples how long the pause
took to report and CHECKs that the DebugScope a real pause creates is still
active. isPaused() answers true for every session while recording or
replaying, so that Replay's pause scripts can inspect the stack where V8 is
not stopped in the debugger, and enableImpl() takes the "already paused" path
on that answer -- enabling Replay's own session at startup would otherwise
send a paused event with no DebugScope and abort node. The sampling is for
pauses a user's session reports, so Replay's own session does not do it.

Rebase note: the invariant is that everything done for a replay-owned
session runs as replay code with events disallowed, while a session a
user or the program attached keeps upstream's behaviour. The flag is
seeded from AreEventsDisallowed() at connect, so new inspector entry
points that touch objects, send notifications or tear state down need
the same AutoMaybeReplayOwned fence, and anything new that creates an
InjectedScript has to pass the flag on.

From #138, #139 and #155.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 12, 2026
@bhackett1024 @Andarist @claude
Add Node.js record/replay driver integration and API
2397c59
Add src/node_recordreplay.cc with Replay's node integration: loading
the driver (InitializeRecordReplay and OpenDriverHandle, from
RECORD_REPLAY_DRIVER or the copy embedded in the binary), the symbol
table of driver function pointers, attaching the recorder with the
build ID, recording the command line arguments and the argv metadata,
and RecordReplayFinishRecording, which appends the recording ID to
RECORD_REPLAY_RECORDING_ID_FILE unless the recording is unusable. The
node::recordreplay namespace holds the helpers the rest of node uses:
callback region scopes, whether the recording has finished, whether a
call is inside a callback the driver intercepts, whether events are
available (recording or replaying, with events neither disallowed nor
passed through and no divergence) or recorded, and
ThrowIfEventsUnavailable, which makes an operation that cannot be
replayed throw instead of running unrecorded.

Expose the recording primitives to JavaScript as process binding
methods: RecordReplayLog, the CDP message pair (a callback for
responses and events, and sending a message through a process-owned
inspector session), the annotation hook, assertions, script ignoring,
the recording ID, the current execution point and elapsed time, and
the external references for all of them. Replay's own session
connects, dispatches and delivers messages to the frontend as replay
code with events disallowed, so none of that work can diverge, and the
session is reset from AtExit, where node normally waits for external
debugger frontends to disconnect: process.exit() skips Environment
destruction, so the session would otherwise survive until static
destruction, after V8's platform has been disposed. That also disables
the debugger, which leaves WebAssembly modules tiered down (see
V8Debugger::disable).

In node.cc, initialize record/replay and mark the sibling group map
ordered before anything else, apply the old space limit the driver
asks for (REPLAY_RECORD_MAX_OLD_SPACE_MB /
REPLAY_REPLAY_MAX_OLD_SPACE_MB, read through
RecordReplayMaxOldSpaceMb) as a V8 flag after the command line's, so
that the arguments and process.execArgv stay the same when replaying,
print the build ID and exit for --print-build-id, create the first
checkpoint on the main thread before the entry script runs, and leave
V8's WebAssembly trap handler disabled while recording/replaying, so
V8 keeps emitting bounds checks instead of relying on a SIGSEGV the
recorder treats as a crash.

libuv keeps a pointer into argv for the process title rather than copying
it, so whichever argv uv_setup_args() sees decides the title. Start()
calls it before InitializeOncePerProcess(), where the driver replaces the
arguments with the recording's, so a replay reported its own argv[0]
instead. Node sends that title to a debugger frontend as the execution
context's name, where it diverged from the recording's and the write to
the frontend's socket was a different length, so the replay sets the
arguments up again once the driver has installed them.

CDP messages from the inspector are accepted as Latin-1: node 26 hands them
over in that encoding, and decoding them as UTF-8 corrupted any message with a
byte above 0x7f.

Rebase note: nearly all of this is new code in
src/node_recordreplay.cc, so conflicts should only come from the call
sites, which are one line each. InitializeRecordReplay() must run
early in InitializeOncePerProcess, before V8, OpenSSL and the platform
are initialized, and the driver's old space limit is applied after
node has processed the command line's V8 options, so that it wins. The
--print-build-id early return sits with the other print-and-exit
options, and StartExecution creates a checkpoint on the main thread
before running the entry script. The process methods are only added to
the process_methods binding, so upstream changes to how bindings
register methods (for example env->SetMethod(target, ...) becoming
SetMethod(context, target, ...) in later v16 releases) must be applied
to these registrations too, and the method names must stay in sync
with lib/internal/bootstrap/node.js.

Includes later changes from #123, #130, #151, #155, #164, #166, #167,

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.