GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add unknown location information to component stacks by sebmarkbage · Pull Request #30290 · react/react

Conversation

@sebmarkbage

@sebmarkbage sebmarkbage commented Jul 7, 2024

Copy link
Copy Markdown
Contributor

This is the same change as in #30289 but for the main runtime - e.g. parent stacks in errorInfo.componentStack, appended stacks to console.error coming from React itself and when we add virtual frames to owner stacks.

Since we don't add location information these frames look weird to some stack parsers - such as the native one. This is an existing issue when you want to use some off-the-shelf parsers to parse production component stacks for example.

While we won't add Error objects to logs ourselves necessarily, some third party could want to do the same thing we do in DevTools and so we should provide the same capability to just take this trace and print it using an Error object.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sebmarkbage
sebmarkbage requested a review from hoxyq July 7, 2024 17:16
@vercel

vercel Bot commented Jul 7, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 7, 2024 10:58pm
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Jul 7, 2024
@vercel
vercel Bot deployed to Preview July 7, 2024 17:18
View deployment
sebmarkbage
sebmarkbage commented Jul 7, 2024
View reviewed changes
Comment thread packages/shared/ReactComponentStackFrame.js
suffix =
x.stack.indexOf('\n at') > -1
? // V8
' (<anonymous>)'

@sebmarkbage sebmarkbage Jul 7, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

At least in Chrome DevTools this is a hardcoded special value that means this doesn't have a location.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sebmarkbage
sebmarkbage commented Jul 7, 2024
View reviewed changes
Comment thread packages/shared/ReactComponentStackFrame.js
' (<anonymous>)'
: // JSC/Spidermonkey
x.stack.indexOf('@') > -1
? '@unknown:0:0'

@sebmarkbage sebmarkbage Jul 7, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This can really be anything include empty '@' but then Firefox can still present it as :0 which is maybe confusing. So the string unknown is just used here to communicate that we don't know the location.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sebmarkbage
sebmarkbage commented Jul 7, 2024
View reviewed changes
Comment thread packages/shared/ReactComponentStackFrame.js

export function describeDebugInfoFrame(name: string, env: ?string): string {
return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : ''));
return describeBuiltInComponentFrame(name + (env ? ' [' + env + ']' : ''));

@sebmarkbage sebmarkbage Jul 7, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This was my original reasoning for parenthesis #28415 (comment)

However, after further research it seems like e.g. (native) is no longer used by V8 and the only non-location is (<anonymous>) so this pattern doesn't follow and it actually gets parsed as if it's a real location.

Meanwhile brackets doesn't seem to have any meaning in any format as far as I can tell from further research so just becomes a name.

All formats are ambiguous when the actual name contains meaningful punctuations like ( or @.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sebmarkbage
Add unknown location information to component stacks
7cb1999
@sebmarkbage
sebmarkbage force-pushed the stacklocations branch from 1728cff to 7cb1999 Compare July 7, 2024 22:56
@vercel
vercel Bot deployed to Preview July 7, 2024 22:58
View deployment
hoxyq
hoxyq approved these changes Jul 8, 2024
View reviewed changes
@sebmarkbage
sebmarkbage merged commit df783f9 into react:main Jul 8, 2024
github-actions Bot pushed a commit that referenced this pull request Jul 8, 2024
@sebmarkbage
Add unknown location information to component stacks (#30290)
d255e1a
This is the same change as in #30289 but for the main runtime - e.g.
parent stacks in errorInfo.componentStack, appended stacks to
console.error coming from React itself and when we add virtual frames to
owner stacks.

Since we don't add location information these frames look weird to some
stack parsers - such as the native one. This is an existing issue when
you want to use some off-the-shelf parsers to parse production component
stacks for example.

While we won't add Error objects to logs ourselves necessarily, some
third party could want to do the same thing we do in DevTools and so we
should provide the same capability to just take this trace and print it
using an Error object.

DiffTrain build for [df783f9](df783f9)
github-actions Bot pushed a commit that referenced this pull request Jul 8, 2024
@sebmarkbage
Add unknown location information to component stacks (#30290)
e99785f
This is the same change as in #30289 but for the main runtime - e.g.
parent stacks in errorInfo.componentStack, appended stacks to
console.error coming from React itself and when we add virtual frames to
owner stacks.

Since we don't add location information these frames look weird to some
stack parsers - such as the native one. This is an existing issue when
you want to use some off-the-shelf parsers to parse production component
stacks for example.

While we won't add Error objects to logs ourselves necessarily, some
third party could want to do the same thing we do in DevTools and so we
should provide the same capability to just take this trace and print it
using an Error object.

DiffTrain build for commit df783f9.
@huozhi huozhi mentioned this pull request Jul 8, 2024
Tweak the display for error trace vercel/next.js#67572
Merged
huozhi added a commit to vercel/next.js that referenced this pull request Jul 9, 2024
@huozhi
Tweak the display for error trace (#67572)
f7bc351
### What

Change the display of error trace in error overlay. 

* Replace unknown location `<anonymous>` from the stack trace but still
keep the content before the location.
* Filter out all `node:` prefixes (including node:async_hooks etc.)



### Why

Regarding to the chaneg in react/react#30290

We only stripped the `(<anonymous>)` part but still keep the first part
of stack trace, e.g. in react it could be the component name.

cc @sebmarkbage
@eps1lon eps1lon mentioned this pull request Jul 16, 2024
Update React from dfd30974ab-20240613 to 01172397-20240716 vercel/next.js#67810
Closed
This was referenced Jul 25, 2024
Update React from 6230622a1a-20240610 to 76002254-20240724 vercel/next.js#68149
Merged
Update React from 6230622a1a-20240610 to 3208e73e-20240730 vercel/next.js#68330
Merged
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@sebmarkbage
Add unknown location information to component stacks (react#30290)
92578b3
This is the same change as in react#30289 but for the main runtime - e.g.
parent stacks in errorInfo.componentStack, appended stacks to
console.error coming from React itself and when we add virtual frames to
owner stacks.

Since we don't add location information these frames look weird to some
stack parsers - such as the native one. This is an existing issue when
you want to use some off-the-shelf parsers to parse production component
stacks for example.

While we won't add Error objects to logs ourselves necessarily, some
third party could want to do the same thing we do in DevTools and so we
should provide the same capability to just take this trace and print it
using an Error object.
@hoxyq hoxyq mentioned this pull request Oct 30, 2026
Improve "native" component stacks host component frames #22531
Closed

This branch was successfully deployed

1 active deployment
Preview — 7cb19992 Deployed Jul 7, 2024 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hoxyq hoxyq hoxyq approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@sebmarkbage @hoxyq @facebook-github-bot
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.