Repository navigation
Let several tools observe JavaScript evaluation (#60562) - #60562
Open
RobertHerhold wants to merge 2 commits into
Open
RobertHerhold wants to merge 2 commits into
RobertHerhold wants to merge 2 commits into
Conversation
|
@RobertHerhold has exported this pull request. If you are a Meta employee, you can view the originating Diff in D136024546. |
RobertHerhold
added a commit
to RobertHerhold/react-native
that referenced
this pull request
Dec 4, 2026
Summary: `setJSEvaluationObserver` kept one process-wide observer, so a second tool installing its own silently disconnected the first. Replace it with `addJSEvaluationObserver` and `removeJSEvaluationObserver`: - Every added observer is called before each evaluation, in the order added. Adding one twice has no effect. - `addJSEvaluationObserver` returns how many evaluations `ReactInstance` had already made in the process, so an observer added after JavaScript ran can tell it missed some. - An exception an observer throws is caught and ignored, so an observer cannot stop JavaScript from loading or keep later observers from running. Changelog: [General][Changed] - Replace `setJSEvaluationObserver` with `addJSEvaluationObserver` and `removeJSEvaluationObserver` Differential Revision: D136024546
RobertHerhold
force-pushed
the
export-D136024546
branch
from
December 4, 2026 18:28
4b701f1 to
a414f0f
Compare
RobertHerhold
added a commit
to RobertHerhold/react-native
that referenced
this pull request
Dec 4, 2026
Summary: `setJSEvaluationObserver` kept one process-wide observer, so a second tool installing its own silently disconnected the first. Replace it with `addJSEvaluationObserver` and `removeJSEvaluationObserver`: - Every added observer is called before each evaluation, in the order added. Adding one twice has no effect. - `addJSEvaluationObserver` returns how many evaluations `ReactInstance` had already made in the process, so an observer added after JavaScript ran can tell it missed some. - An exception an observer throws is caught and ignored, so an observer cannot stop JavaScript from loading or keep later observers from running. Changelog: [General][Changed] - Replace `setJSEvaluationObserver` with `addJSEvaluationObserver` and `removeJSEvaluationObserver` Differential Revision: D136024546 Signed-off-by: Rob Herhold <rherhold@meta.com>
RobertHerhold
force-pushed
the
export-D136024546
branch
from
December 4, 2026 18:36
a414f0f to
f7dc4d9
Compare
RobertHerhold
added a commit
to RobertHerhold/react-native
that referenced
this pull request
Dec 4, 2026
Summary: `setJSEvaluationObserver` kept one process-wide observer, so a second tool installing its own silently disconnected the first. Replace it with `addJSEvaluationObserver` and `removeJSEvaluationObserver`: - Every added observer is called before each evaluation, in the order added. Adding one twice has no effect. - `addJSEvaluationObserver` returns how many evaluations `ReactInstance` had already made in the process, so an observer added after JavaScript ran can tell it missed some. - An exception an observer throws is caught and ignored, so an observer cannot stop JavaScript from loading or keep later observers from running. Changelog: [General][Changed] - Replace `setJSEvaluationObserver` with `addJSEvaluationObserver` and `removeJSEvaluationObserver` Differential Revision: D136024546
RobertHerhold
force-pushed
the
export-D136024546
branch
from
December 4, 2026 21:38
f7dc4d9 to
e9804aa
Compare
…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
Summary: `setJSEvaluationObserver` kept one process-wide observer, so a second tool installing its own silently disconnected the first. Replace it with `addJSEvaluationObserver` and `removeJSEvaluationObserver`: - Every added observer is called before each evaluation, in the order added. Adding one twice has no effect. - `addJSEvaluationObserver` returns how many evaluations `ReactInstance` had already made in the process, so an observer added after JavaScript ran can tell it missed some. - An exception an observer throws is caught and ignored, so an observer cannot stop JavaScript from loading or keep later observers from running. Changelog: [General][Changed] - Replace `setJSEvaluationObserver` with `addJSEvaluationObserver` and `removeJSEvaluationObserver` Differential Revision: D136024546
RobertHerhold
force-pushed
the
export-D136024546
branch
from
December 4, 2026 21:57
e9804aa to
93cabed
Compare
This branch has not been deployed
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.
Summary:
setJSEvaluationObserverkept one process-wide observer, so a second tool installing its own silently disconnected the first. Replace it withaddJSEvaluationObserverandremoveJSEvaluationObserver:addJSEvaluationObserverreturns how many evaluationsReactInstancehad already made in the process, so an observer added after JavaScript ran can tell it missed some.Changelog:
[General][Changed] - Replace
setJSEvaluationObserverwithaddJSEvaluationObserverandremoveJSEvaluationObserverDifferential Revision: D136024546