-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import {disableLogs, reenableLogs} from 'shared/ConsolePatchingDev'; | |
import ReactSharedInternals from 'shared/ReactSharedInternals'; | ||
|
||
let prefix; | ||
let suffix; | ||
export function describeBuiltInComponentFrame(name: string): string { | ||
if (enableComponentStackLocations) { | ||
if (prefix === undefined) { | ||
|
@@ -33,17 +34,26 @@ export function describeBuiltInComponentFrame(name: string): string { | |
} catch (x) { | ||
const match = x.stack.trim().match(/\n( *(at )?)/); | ||
prefix = (match && match[1]) || ''; | ||
suffix = | ||
x.stack.indexOf('\n at') > -1 | ||
? // V8 | ||
' (<anonymous>)' | ||
: // JSC/Spidermonkey | ||
x.stack.indexOf('@') > -1 | ||
? '@unknown:0:0' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can really be anything include empty |
||
: // Other | ||
''; | ||
} | ||
} | ||
// We use the prefix to ensure our stacks line up with native stack frames. | ||
return '\n' + prefix + name; | ||
return '\n' + prefix + name + suffix; | ||
} 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 commentThe 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. 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 |
||
} | ||
|
||
let reentry = false; | ||
|
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.