-
Notifications
You must be signed in to change notification settings - Fork 46.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unknown location information to component stacks #30290
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
suffix = | ||
x.stack.indexOf('\n at') > -1 | ||
? // V8 | ||
' (<anonymous>)' |
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.
' (<anonymous>)' | ||
: // JSC/Spidermonkey | ||
x.stack.indexOf('@') > -1 | ||
? '@unknown:0:0' |
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.
} else { | ||
return describeComponentFrame(name); | ||
} | ||
} | ||
|
||
export function describeDebugInfoFrame(name: string, env: ?string): string { | ||
return describeBuiltInComponentFrame(name + (env ? ' (' + env + ')' : '')); | ||
return describeBuiltInComponentFrame(name + (env ? ' [' + env + ']' : '')); |
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 @
.
1728cff
to
7cb1999
Compare
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)
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.
### 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 facebook/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
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.