Skip to content

Conversation

@sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Jul 21, 2025

In RSC and other stacks now we use a lot of ReactFunctionLocation type to represent the location of a function. I.e. the location of the beginning of the function (the enclosing line/col) that is represented by the "Source" of the function. This is also what the parent Component Stacks represents.

As opposed to ReactCallSite which is what normal stack traces and owner stacks represent. I.e. the line/column number of the callsite into the next function.

We can start sharing more code by using the ReactFunctionLocation type to represent the component source location and it also helps clarify which ones are function locations and which ones are callsites as we start adding more stack traces (e.g. for async debug info and owner stack traces).

This collects locations from parent Component Stacks. These are conceptually
ReactFunctionLocations (top of the function) as opposed to ReactCallSite that
are usually part of stacks like owner stacks.
Ideally we'd parse the function name out of the sourceContent of the original
position.
@sebmarkbage sebmarkbage requested a review from hoxyq July 21, 2025 21:40
@meta-cla meta-cla bot added the CLA Signed label Jul 21, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Jul 21, 2025
export type ViewElementSource = (
source: Source,
symbolicatedSource: Source | null,
source: ReactFunctionLocation,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know if there are any consumers of this in fusebox that needs to be updated. If so, it's probably just the same as the standalone.

https://github.com/facebook/react/pull/33955/files#diff-44b2457a5630ea27596ba5182ef5ec7427b63b6aa2cb4143083eb321e8a12752R153

Copy link
Contributor

Choose a reason for hiding this comment

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

This package is private and the only user is React Native DevTools.

This should be fine, I will update this next time I upgrade React DevTools for React Native DevTools.

source: source && source.sourceURL ? source : null,
// Previous backend implementations (<= 6.1.5) have a different interface for Source.
// This gates the source features for only compatible backends: >= 6.1.6
source: Array.isArray(source) ? source : null,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure where this is needed but following the same pattern.

Copy link
Contributor

@hoxyq hoxyq Jul 22, 2025

Choose a reason for hiding this comment

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

This is needed in case there is a version mismatch between Backend and Frontend. Not applicable to browser extensions, only to standalone / inline / fusebox versions, where only Frontend is shipped, and Backend is used from react-devtools-core npm package.

For example, if Frontend would have your change, but Backend didn't, there would be type mismatch and Frontend would potentially treat plain object as an array.

@sebmarkbage sebmarkbage merged commit 7513996 into facebook:main Jul 22, 2025
248 checks passed
github-actions bot pushed a commit to code/lib-react that referenced this pull request Jul 26, 2025
facebook#33955)

In RSC and other stacks now we use a lot of `ReactFunctionLocation` type
to represent the location of a function. I.e. the location of the
beginning of the function (the enclosing line/col) that is represented
by the "Source" of the function. This is also what the parent Component
Stacks represents.

As opposed to `ReactCallSite` which is what normal stack traces and
owner stacks represent. I.e. the line/column number of the callsite into
the next function.

We can start sharing more code by using the `ReactFunctionLocation` type
to represent the component source location and it also helps clarify
which ones are function locations and which ones are callsites as we
start adding more stack traces (e.g. for async debug info and owner
stack traces).

DiffTrain build for [7513996](facebook@7513996)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Jul 26, 2025
facebook#33955)

In RSC and other stacks now we use a lot of `ReactFunctionLocation` type
to represent the location of a function. I.e. the location of the
beginning of the function (the enclosing line/col) that is represented
by the "Source" of the function. This is also what the parent Component
Stacks represents.

As opposed to `ReactCallSite` which is what normal stack traces and
owner stacks represent. I.e. the line/column number of the callsite into
the next function.

We can start sharing more code by using the `ReactFunctionLocation` type
to represent the component source location and it also helps clarify
which ones are function locations and which ones are callsites as we
start adding more stack traces (e.g. for async debug info and owner
stack traces).

DiffTrain build for [7513996](facebook@7513996)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants