Skip to content

Let development tooling observe each JavaScript buffer ReactInstance evaluates (#60561) - #60561

Open
RobertHerhold wants to merge 1 commit into
react:mainfrom
RobertHerhold:export-D136024543
Open

RobertHerhold wants to merge 1 commit into
react:mainfrom
RobertHerhold:export-D136024543

Conversation

@RobertHerhold

@RobertHerhold RobertHerhold commented Dec 4, 2026 •

Copy link
Copy Markdown

Summary:

Development tooling sometimes needs to know exactly which JavaScript a process ran, for example to tie a recording to the source it came from. ReactInstance evaluates JavaScript in four places: the main bundle (loadScript), segments registered from files (registerSegment), source evaluated through globalEvalWithSourceUrl (lazy segments fetched from a dev server and Fast Refresh updates), and Static Hermes units compiled into the binary.

This adds setJSEvaluationObserver, a process-wide hook in react/runtime/JSEvaluationObserver.h. ReactInstance calls the installed observer on the JS thread immediately before each evaluation, with the exact bytes it is about to evaluate, the source URL and the kind of evaluation. With no observer installed, each path only counts the evaluation; setJSEvaluationObserver returns that count, so an observer installed late can tell that it missed some.

The header is in the for-frameworks tier, like ReactMarker.

Changelog:
[General][Added] - Add setJSEvaluationObserver to observe the JavaScript ReactInstance evaluates

Differential Revision: D136024543

@meta-codesync

meta-codesync Bot commented Dec 4, 2026

Copy link
Copy Markdown

@RobertHerhold has exported this pull request. If you are a Meta employee, you can view the originating Diff in D136024543.

RobertHerhold added a commit to RobertHerhold/react-native that referenced this pull request Dec 4, 2026
…evaluates (react#60561)

Summary:

Development tooling sometimes needs to know exactly which JavaScript a process ran, for example to tie a recording to the source it came from. `ReactInstance` evaluates JavaScript in four places: the main bundle (`loadScript`), segments registered from files (`registerSegment`), source evaluated through `globalEvalWithSourceUrl` (lazy segments fetched from a dev server and Fast Refresh updates), and Static Hermes units compiled into the binary.

This adds `setJSEvaluationObserver`, a process-wide hook in `react/runtime/JSEvaluationObserver.h`. `ReactInstance` calls the installed observer on the JS thread immediately before each evaluation, with the exact bytes it is about to evaluate, the source URL and the kind of evaluation. With no observer installed, each path only counts the evaluation; `setJSEvaluationObserver` returns that count, so an observer installed late can tell that it missed some.

The header is in the for-frameworks tier, like `ReactMarker`.

Changelog:
[General][Added] - Add `setJSEvaluationObserver` to observe the JavaScript `ReactInstance` evaluates

Differential Revision: D136024543
@meta-codesync meta-codesync Bot changed the title Let development tooling observe each JavaScript buffer ReactInstance evaluates Let development tooling observe each JavaScript buffer ReactInstance evaluates (#60561) Dec 4, 2026
RobertHerhold added a commit to RobertHerhold/react-native that referenced this pull request Dec 4, 2026
…evaluates (react#60561)

Summary:

Development tooling sometimes needs to know exactly which JavaScript a process ran, for example to tie a recording to the source it came from. `ReactInstance` evaluates JavaScript in four places: the main bundle (`loadScript`), segments registered from files (`registerSegment`), source evaluated through `globalEvalWithSourceUrl` (lazy segments fetched from a dev server and Fast Refresh updates), and Static Hermes units compiled into the binary.

This adds `setJSEvaluationObserver`, a process-wide hook in `react/runtime/JSEvaluationObserver.h`. `ReactInstance` calls the installed observer on the JS thread immediately before each evaluation, with the exact bytes it is about to evaluate, the source URL and the kind of evaluation. With no observer installed, each path only counts the evaluation; `setJSEvaluationObserver` returns that count, so an observer installed late can tell that it missed some.

The header is in the for-frameworks tier, like `ReactMarker`.

Changelog:
[General][Added] - Add `setJSEvaluationObserver` to observe the JavaScript `ReactInstance` evaluates

Differential Revision: D136024543
RobertHerhold added a commit to RobertHerhold/react-native that referenced this pull request Dec 4, 2026
…evaluates (react#60561)

Summary:

Development tooling sometimes needs to know exactly which JavaScript a process ran, for example to tie a recording to the source it came from. `ReactInstance` evaluates JavaScript in four places: the main bundle (`loadScript`), segments registered from files (`registerSegment`), source evaluated through `globalEvalWithSourceUrl` (lazy segments fetched from a dev server and Fast Refresh updates), and Static Hermes units compiled into the binary.

This adds `setJSEvaluationObserver`, a process-wide hook in `react/runtime/JSEvaluationObserver.h`. `ReactInstance` calls the installed observer on the JS thread immediately before each evaluation, with the exact bytes it is about to evaluate, the source URL and the kind of evaluation. With no observer installed, each path only counts the evaluation; `setJSEvaluationObserver` returns that count, so an observer installed late can tell that it missed some.

The header is in the for-frameworks tier, like `ReactMarker`.

Changelog:
[General][Added] - Add `setJSEvaluationObserver` to observe the JavaScript `ReactInstance` evaluates

Differential Revision: D136024543




Signed-off-by: Rob Herhold <rherhold@meta.com>
RobertHerhold added a commit to RobertHerhold/react-native that referenced this pull request Dec 4, 2026
…evaluates (react#60561)

Summary:

Development tooling sometimes needs to know exactly which JavaScript a process ran, for example to tie a recording to the source it came from. `ReactInstance` evaluates JavaScript in four places: the main bundle (`loadScript`), segments registered from files (`registerSegment`), source evaluated through `globalEvalWithSourceUrl` (lazy segments fetched from a dev server and Fast Refresh updates), and Static Hermes units compiled into the binary.

This adds `setJSEvaluationObserver`, a process-wide hook in `react/runtime/JSEvaluationObserver.h`. `ReactInstance` calls the installed observer on the JS thread immediately before each evaluation, with the exact bytes it is about to evaluate, the source URL and the kind of evaluation. With no observer installed, each path only counts the evaluation; `setJSEvaluationObserver` returns that count, so an observer installed late can tell that it missed some.

The header is in the for-frameworks tier, like `ReactMarker`.

Changelog:
[General][Added] - Add `setJSEvaluationObserver` to observe the JavaScript `ReactInstance` evaluates

Differential Revision: D136024543
…evaluates (react#60561)

Summary:

Development tooling sometimes needs to know exactly which JavaScript a process ran, for example to tie a recording to the source it came from. `ReactInstance` evaluates JavaScript in four places: the main bundle (`loadScript`), segments registered from files (`registerSegment`), source evaluated through `globalEvalWithSourceUrl` (lazy segments fetched from a dev server and Fast Refresh updates), and Static Hermes units compiled into the binary.

This adds `setJSEvaluationObserver`, a process-wide hook in `react/runtime/JSEvaluationObserver.h`. `ReactInstance` calls the installed observer on the JS thread immediately before each evaluation, with the exact bytes it is about to evaluate, the source URL and the kind of evaluation. With no observer installed, each path only counts the evaluation; `setJSEvaluationObserver` returns that count, so an observer installed late can tell that it missed some.

The header is in the for-frameworks tier, like `ReactMarker`.

Changelog:
[General][Added] - Add `setJSEvaluationObserver` to observe the JavaScript `ReactInstance` evaluates

Differential Revision: D136024543
RobertHerhold added a commit to RobertHerhold/react-native that referenced this pull request Dec 4, 2026
…evaluates (react#60561)

Summary:

Development tooling sometimes needs to know exactly which JavaScript a process ran, for example to tie a recording to the source it came from. `ReactInstance` evaluates JavaScript in four places: the main bundle (`loadScript`), segments registered from files (`registerSegment`), source evaluated through `globalEvalWithSourceUrl` (lazy segments fetched from a dev server and Fast Refresh updates), and Static Hermes units compiled into the binary.

This adds `setJSEvaluationObserver`, a process-wide hook in `react/runtime/JSEvaluationObserver.h`. `ReactInstance` calls the installed observer on the JS thread immediately before each evaluation, with the exact bytes it is about to evaluate, the source URL and the kind of evaluation. With no observer installed, each path only counts the evaluation; `setJSEvaluationObserver` returns that count, so an observer installed late can tell that it missed some.

The header is in the for-frameworks tier, like `ReactMarker`.

Changelog:
[General][Added] - Add `setJSEvaluationObserver` to observe the JavaScript `ReactInstance` evaluates

Differential Revision: D136024543

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant