Skip to content

Replay Error.stack and error messages - #137

Merged
Andarist merged 7 commits into
masterfrom
replay-error-stacks
Sep 22, 2026
Merged

Andarist merged 7 commits into
masterfrom
replay-error-stacks

Conversation

@Andarist

@Andarist Andarist commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Port of the Chromium fork's [PRO-1150] changes (Replay error stacks, Replay error messages in MessageFormatter::Format, and the follow-ups that skip both while events are disallowed and don't cache a stack formatted for a replay-only read). Error.stack can differ between recording and replaying even though the same code runs, since which frames V8 reports depends on JIT state and the replay deoptimizes code the recording never did; recording the formatted string makes the replayed one identical.

Node formats every stack through its prepareStackTrace callback, which returns before the internal formatter Chromium's change hooks, so the recording wraps the whole of FormatStackTrace. The callback's result need not be a string, so whether a string was recorded is recorded as well.

Ports:
replayio/chromium-v8#270
replayio/chromium-v8#272
replayio/chromium-v8#278
replayio/chromium-v8#280

tested with https://github.com/replayio/backend/pull/13371

Port of the Chromium fork's [PRO-1150] changes (Replay error stacks,
Replay error messages in MessageFormatter::Format, and the follow-ups that
skip both while events are disallowed and don't cache a stack formatted for
a replay-only read). Error.stack can differ between recording and
replaying even though the same code runs, since which frames V8 reports
depends on JIT state and the replay deoptimizes code the recording never
did; recording the formatted string makes the replayed one identical.

Node formats every stack through its prepareStackTrace callback, which
returns before the internal formatter Chromium's change hooks, so the
recording wraps the whole of FormatStackTrace. The callback's result need
not be a string, so whether a string was recorded is recorded as well.
The formatted Error.stack and error messages were recorded by converting
them to UTF-8 with String::ToCString and back with NewStringFromUtf8, and
the converted string was used while recording too. That loses unpaired
surrogates (each comes back as up to three U+FFFD), so the program saw
different strings while being recorded than it does normally. Chromium's
version additionally turns NULs into spaces through ToCString's default.

Record the string's UTF-16 code units instead and rebuild it with
NewStringFromTwoByte, which yields a one-byte string when every unit fits,
so the string is identical to the original in both runs. This also drops
the RecordReplayString helper, which has no other users.
Comment thread deps/v8/src/execution/messages.cc Outdated
// Chromium fork does. Node formats through its prepareStackTrace callback,
// whose result need not be a string, so whether one was recorded is recorded
// as well.
MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why this wraps the whole function, unlike Chromium

Chromium records Error.stack only at the end of V8's built-in formatter. Both prepareStackTrace branches (the embedder callback and a user's Error.prepareStackTrace) return before that point and aren't recorded. That works in Chromium because Blink never installs a PrepareStackTraceCallback, so nearly every stack comes from the built-in formatter.

Node always installs that callback: prepareStackTrace in lib/internal/errors.js formats every stack, and calls a user's Error.prepareStackTrace when there is one. With Chromium's placement node would record nothing, so the port wraps the whole function and records all branches. A callback may return something that isn't a string, so it also records whether the result was a string.

prepareStackTrace considerations

  • Node: the callback is JS, and it still runs during replay, over the replay's own call sites. Only its result is replaced.
  • Chromium: a page's own Error.prepareStackTrace isn't recorded. Such callbacks usually return structured call sites, not a string, and would run again during replay regardless. So the only gap is a page callback that returns a string over frames that differ. It could be covered by recording at the same point as here

Comment thread deps/v8/src/execution/messages.cc Outdated
// made of the recorded ones while replaying. Copying code units instead of
// converting to UTF-8 keeps NULs and unpaired surrogates intact, so the
// program sees the same string it would without being recorded.
Handle<String> RecordReplayStringContents(Isolate* isolate, const char* why,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This version is an improvement over the one we have in Chromium. It's supposed to handle certain characters better - I have verified the results between non-recording replay-node and the recording one. With a chromium-style patch we would actually fail to preserve those utf16 input~ correctly.

Port Chromium's feature-aware IsRecordingOrReplaying(feature, subfeature)
and FeatureEnabled, backed by the driver's RecordReplayFeatureEnabled, and
gate recording error stacks and messages on the same feature names
Chromium uses, so RECORD_REPLAY_DISABLE_FEATURES turns them off in both.
Match the name and contract of Chromium's v8::replayio helper: overloads
for Handle and MaybeHandle, returning the input unchanged when the
feature named by why isn't recorded. It stays in messages.cc, its only
user, as the node fork has no src/replay.
Put the recording wrapper where the original function was and move its
body below as FormatStackTraceImpl, declared ahead in the anonymous
namespace with the other helpers.
@Andarist
Andarist merged commit 4028145 into master Sep 22, 2026
3 checks passed
bhackett1024 pushed a commit that referenced this pull request Nov 5, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 6, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 10, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist pushed a commit that referenced this pull request Nov 11, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 11, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 11, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 11, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 11, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 11, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Andarist added a commit that referenced this pull request Nov 12, 2026
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.

Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.

The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <Domiii@users.noreply.github.com>
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist added a commit that referenced this pull request Nov 12, 2026
Node formats every stack through its prepareStackTrace callback, which
can return any value, so record whether the result was a string and the
string itself, then replay it verbatim. RecordReplayStringHandle copies
UTF-16 code units rather than converting to UTF-8, so NULs and unpaired
surrogates survive. Record MessageFormatter::Format the same way.

While events are disallowed, don't cache the formatted stack back onto
the error object, so inspecting an error during replay does not change
the program's state. (PRO-1150, PRO-2368)

From #137.

Co-authored-by: Brian Hackett <bhackett1024@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants