Skip to content

Commit f085c83

Browse files
committed
[devtools] fix: fallback to reading string stack trace when failed
1 parent 9fd4c09 commit f085c83

File tree

1 file changed

+7
-1
lines changed
  • packages/react-devtools-shared/src/backend/utils

1 file changed

+7
-1
lines changed

packages/react-devtools-shared/src/backend/utils/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ function collectStackTrace(
381381
// $FlowFixMe[prop-missing]
382382
typeof callSite.getEnclosingColumnNumber === 'function'
383383
? (callSite: any).getEnclosingColumnNumber()
384-
: callSite.getLineNumber();
384+
: callSite.getColumnNumber();
385385
if (!sourceURL || !line || !col) {
386386
// Skip eval etc. without source url. They don't have location.
387387
continue;
@@ -412,12 +412,18 @@ export function parseSourceFromOwnerStack(error: Error): Source | null {
412412
let stack;
413413
try {
414414
stack = error.stack;
415+
} catch (e) {
416+
Error.prepareStackTrace = undefined;
417+
stack = error.stack;
415418
} finally {
416419
Error.prepareStackTrace = previousPrepare;
417420
}
418421
if (collectedLocation !== null) {
419422
return collectedLocation;
420423
}
424+
if (stack == null) {
425+
return null;
426+
}
421427
// Fallback to parsing the string form.
422428
const componentStack = formatOwnerStackString(stack);
423429
return parseSourceFromComponentStack(componentStack);

0 commit comments

Comments
 (0)