Skip to content

Commit b8df429

Browse files
committed
Protect against generating stacks failing
Errors while generating stacks will bubble to the root. Since this technique is a bit sketchy, we should probably protect against it.
1 parent 29bc28a commit b8df429

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

packages/react-reconciler/src/ReactFiberComponentStack.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@ function describeFiber(fiber: Fiber): string {
5959
}
6060

6161
export function getStackByFiberInDevAndProd(workInProgress: Fiber): string {
62-
let info = '';
63-
let node = workInProgress;
64-
do {
65-
info += describeFiber(node);
66-
node = node.return;
67-
} while (node);
68-
return info;
62+
try {
63+
let info = '';
64+
let node = workInProgress;
65+
do {
66+
info += describeFiber(node);
67+
node = node.return;
68+
} while (node);
69+
return info;
70+
} catch (x) {
71+
return '\nError generating stack: ' + x.message + '\n' + x.stack;
72+
}
6973
}

0 commit comments

Comments
 (0)