mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
[devtools] fix: fallback to reading string stack trace when failed (#33700)
Discovered while testing with Hermes.
This commit is contained in:
@@ -381,7 +381,7 @@ function collectStackTrace(
|
||||
// $FlowFixMe[prop-missing]
|
||||
typeof callSite.getEnclosingColumnNumber === 'function'
|
||||
? (callSite: any).getEnclosingColumnNumber()
|
||||
: callSite.getLineNumber();
|
||||
: callSite.getColumnNumber();
|
||||
if (!sourceURL || !line || !col) {
|
||||
// Skip eval etc. without source url. They don't have location.
|
||||
continue;
|
||||
@@ -412,12 +412,19 @@ export function parseSourceFromOwnerStack(error: Error): Source | null {
|
||||
let stack;
|
||||
try {
|
||||
stack = error.stack;
|
||||
} catch (e) {
|
||||
// $FlowFixMe[incompatible-type] It does accept undefined.
|
||||
Error.prepareStackTrace = undefined;
|
||||
stack = error.stack;
|
||||
} finally {
|
||||
Error.prepareStackTrace = previousPrepare;
|
||||
}
|
||||
if (collectedLocation !== null) {
|
||||
return collectedLocation;
|
||||
}
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
// Fallback to parsing the string form.
|
||||
const componentStack = formatOwnerStackString(stack);
|
||||
return parseSourceFromComponentStack(componentStack);
|
||||
|
||||
Reference in New Issue
Block a user