Repository navigation
Send recording warnings to the driver as structured kind + data - #202
Merged
Merged
Conversation
The driver no longer exports the printf-style RecordReplayWarning; warnings
are now a kind (a PascalCase name for the condition) plus typed detail fields,
handed to RecordReplayStructuredWarning so they can be reported as telemetry
events (replayio/backend driver change on andarist/recording-warning-telemetry).
recordreplay::Warning now takes a kind and an initializer list of
RecordReplayWarningField (declared in replayio-macros.h with the driver's
layout), and V8RecordReplayWarning is replaced by
V8RecordReplayStructuredWarning. The V8 call sites become:
- OnProgressReached -> TargetProgressReachedWithEventsDisallowed {progress}
- <kind>:BLOCKED:NonDeterministicUserJS -> NonDeterministicUserJSBlocked
{trigger, progress, detail, jsStack}
- NonDeterministicUserJS:UNGATED:JSProgress -> NonDeterministicUserJSUngated
{trigger, progress, scriptId, location, jsStack}
The last two use the same kinds as the equivalent replayio/chromium-v8 change.
bhackett1024
pushed a commit
that referenced
this pull request
Nov 5, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
added a commit
that referenced
this pull request
Nov 6, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.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
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.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
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@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
pushed a commit
that referenced
this pull request
Nov 6, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 6, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 6, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
added a commit
that referenced
this pull request
Nov 6, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
added a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
added a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Reading a property's descriptor can run user code too: node defines its lazy globals (FormData, Headers, Request, Response, WebSocket, ...) with SetLazyDataProperty, whose replace-on-access getter loads the module, and on the global proxy the inspector does not report them as native accessors. Replay's own session describes the global object for every pause's scope chain with events disallowed, where loading undici needs recorded calls the recording does not have. Report a lazy data property that has not loaded yet as a native getter instead, as the inspector does for other native accessors; a session a user or the program attached runs with events allowed and still loads it. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 10, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Reading a property's descriptor can run user code too: node defines its lazy globals (FormData, Headers, Request, Response, WebSocket, ...) with SetLazyDataProperty, whose replace-on-access getter loads the module, and on the global proxy the inspector does not report them as native accessors. Replay's own session describes the global object for every pause's scope chain with events disallowed, where loading undici needs recorded calls the recording does not have. Report a lazy data property that has not loaded yet as a native getter instead, as the inspector does for other native accessors; a session a user or the program attached runs with events allowed and still loads it. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
pushed a commit
that referenced
this pull request
Nov 11, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Reading a property's descriptor can run user code too: node defines its lazy globals (FormData, Headers, Request, Response, WebSocket, ...) with SetLazyDataProperty, whose replace-on-access getter loads the module, and on the global proxy the inspector does not report them as native accessors. Replay's own session describes the global object for every pause's scope chain with events disallowed, where loading undici needs recorded calls the recording does not have. Report a lazy data property that has not loaded yet as a native getter instead, as the inspector does for other native accessors; a session a user or the program attached runs with events allowed and still loads it. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
added a commit
that referenced
this pull request
Nov 11, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Reading a property's descriptor can run user code too: node defines its lazy globals (FormData, Headers, Request, Response, WebSocket, ...) with SetLazyDataProperty, whose replace-on-access getter loads the module, and on the global proxy the inspector does not report them as native accessors. Replay's own session describes the global object for every pause's scope chain with events disallowed, where loading undici needs recorded calls the recording does not have. Report a lazy data property that has not loaded yet as a native getter instead, as the inspector does for other native accessors; a session a user or the program attached runs with events allowed and still loads it. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
added a commit
that referenced
this pull request
Nov 11, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Reading a property's descriptor can run user code too: node defines its lazy globals (FormData, Headers, Request, Response, WebSocket, ...) with SetLazyDataProperty, whose replace-on-access getter loads the module, and on the global proxy the inspector does not report them as native accessors. Replay's own session describes the global object for every pause's scope chain with events disallowed, where loading undici needs recorded calls the recording does not have. Report a lazy data property that has not loaded yet as a native getter instead, as the inspector does for other native accessors; a session a user or the program attached runs with events allowed and still loads it. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Andarist
added a commit
that referenced
this pull request
Nov 12, 2026
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Reading a property's descriptor can run user code too: node defines its lazy globals (FormData, Headers, Request, Response, WebSocket, ...) with SetLazyDataProperty, whose replace-on-access getter loads the module, and on the global proxy the inspector does not report them as native accessors. Replay's own session describes the global object for every pause's scope chain with events disallowed, where loading undici needs recorded calls the recording does not have. Report a lazy data property that has not loaded yet as a native getter instead, as the inspector does for other native accessors; a session a user or the program attached runs with events allowed and still loads it. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> Co-authored-by: Brian Hackett <bhackett1024@gmail.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.