Skip to content

Commit

Permalink
Protect against generating stacks failing
Browse files Browse the repository at this point in the history
Errors while generating stacks will bubble to the root. Since this technique
is a bit sketchy, we should probably protect against it.
  • Loading branch information
sebmarkbage committed Apr 11, 2020
1 parent 29bc28a commit b8df429
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/react-reconciler/src/ReactFiberComponentStack.js
Expand Up @@ -59,11 +59,15 @@ function describeFiber(fiber: Fiber): string {
}

export function getStackByFiberInDevAndProd(workInProgress: Fiber): string {
let info = '';
let node = workInProgress;
do {
info += describeFiber(node);
node = node.return;
} while (node);
return info;
try {
let info = '';
let node = workInProgress;
do {
info += describeFiber(node);
node = node.return;
} while (node);
return info;
} catch (x) {
return '\nError generating stack: ' + x.message + '\n' + x.stack;
}
}

0 comments on commit b8df429

Please sign in to comment.