Skip to content

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Aug 4, 2025

Stacked on #34093.

Instead of using the original ReactStackTrace that has the call sites on the server, this parses the Error object which has the virtual call sites on the client. We'll need this technique for things stack traces suspending on the client anyway like use().

We can then use these callsites to source map in the front end.

We currently don't source map function names but might be useful for this use case as well as getting original component names from prod.

One thing this doesn't do yet is that it doesn't ignore list the stack traces on the client using the source map's ignore list setting. It's not super important since we expect to have already ignore listed on the server but this will become important for client stack traces like use().

@sebmarkbage sebmarkbage requested a review from eps1lon August 4, 2025 02:35
@meta-cla meta-cla bot added the CLA Signed label Aug 4, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Aug 4, 2025

const symbolicatedCallSite: null | ReactFunctionLocation =
fetchFileWithCaching !== null
? use(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we give up on supporting older React versions for react-devtools-inline?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you mean older React versions? It's all versions if the react-devtools-inline host isn't providing a way to fetch the files?

Older versions won't get any stacks anyway since it won't exist in the data.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant using use which doesn't exist in all versions of React. The frontend is currently written in a way that makes it compatible with older versions of React. So if you implement fetchFileWithCaching but are using React 17 for some reason for the frontend, you'll get error if you're inspecting newer React.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We already use it elsewhere so I guess we don't support that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't see those. Feels odd that we check in some places but not all e.g.

columnNumber, // 1-based
});

const column = columnZeroBased + 1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This fixes an existing issue where we were returning a zero based column when the data structure expects a one based column.

sebmarkbage added a commit that referenced this pull request Aug 6, 2025
… different owner (#34101)

Stacked on #34094.

This shows the I/O stack if available. If it's not available or if it
has a different owner (like if it was passed in) then we show the
`"awaited at:"` stack below it so you can see where it started and where
it was awaited. If it's the same owner this tends to be unnecessary
noise. We could maybe be smarter if the stacks are very different then
you might want to show both even with the same owner.

<img width="517" height="478" alt="Screenshot 2025-08-04 at 11 57 28 AM"
src="https://github.com/user-attachments/assets/2dbfbed4-4671-4a5f-8e6e-ebec6fe8a1b7"
/>

Additionally, this adds an inferred await if there's no owner and no
stack for the await. The inferred await of a function/class component is
just the owner. No stack. Because the stack trace would be the return
value. This will also be the case if you use throw-a-Promise. The
inferred await in the child position of a built-in is the JSX location
of that await like if you pass a promise to a child. This inference
already happens when you pass a Promise from RSC so in this case it
already has an await - so this is mainly for client promises.
…d in ReactCallSite and ReactFunctionLocation
@sebmarkbage sebmarkbage force-pushed the devtoolssourcemapstacks branch from 7d23f6f to dded82b Compare August 6, 2025 17:00
@sebmarkbage sebmarkbage merged commit b080063 into facebook:main Aug 6, 2025
241 checks passed
@sebmarkbage
Copy link
Collaborator Author

The main one landed as part of #34101. The landed part here is just the fix to columns.

github-actions bot pushed a commit to code/lib-react that referenced this pull request Aug 9, 2025
…34094)

Stacked on facebook#34093.

Instead of using the original `ReactStackTrace` that has the call sites
on the server, this parses the `Error` object which has the virtual call
sites on the client. We'll need this technique for things stack traces
suspending on the client anyway like `use()`.

We can then use these callsites to source map in the front end.

We currently don't source map function names but might be useful for
this use case as well as getting original component names from prod.

One thing this doesn't do yet is that it doesn't ignore list the stack
traces on the client using the source map's ignore list setting. It's
not super important since we expect to have already ignore listed on the
server but this will become important for client stack traces like
`use()`.

DiffTrain build for [b080063](facebook@b080063)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Aug 9, 2025
…34094)

Stacked on facebook#34093.

Instead of using the original `ReactStackTrace` that has the call sites
on the server, this parses the `Error` object which has the virtual call
sites on the client. We'll need this technique for things stack traces
suspending on the client anyway like `use()`.

We can then use these callsites to source map in the front end.

We currently don't source map function names but might be useful for
this use case as well as getting original component names from prod.

One thing this doesn't do yet is that it doesn't ignore list the stack
traces on the client using the source map's ignore list setting. It's
not super important since we expect to have already ignore listed on the
server but this will become important for client stack traces like
`use()`.

DiffTrain build for [b080063](facebook@b080063)
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