Skip to content

Commit 060b884

Browse files
committed
Consider all React bottom frame formats
1 parent 259586d commit 060b884

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

packages/next/src/next-devtools/dev-overlay/shared.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,11 @@ export type DispatcherEvent =
214214
| RestartServerButtonAction
215215

216216
const REACT_ERROR_STACK_BOTTOM_FRAME_REGEX =
217-
// 1st group: v8
218-
// 2nd group: SpiderMonkey, JavaScriptCore
219-
/\s+(at react-stack-bottom-frame.*)|(react-stack-bottom-frame@.*)/
217+
// 1st group: new frame + v8
218+
// 2nd group: new frame + SpiderMonkey, JavaScriptCore
219+
// 3rd group: old frame + v8
220+
// 4th group: old frame + SpiderMonkey, JavaScriptCore
221+
/\s+(at Object\.react_stack_bottom_frame.*)|(react_stack_bottom_frame@.*)|(at react-stack-bottom-frame.*)|(react-stack-bottom-frame@.*)/
220222

221223
// React calls user code starting from a special stack frame.
222224
// The basic stack will be different if the same error location is hit again

packages/next/src/server/patch-error-inspect.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,14 @@ function parseAndSourceMap(
357357
// doesn't implement the name computation correctly.
358358
const errorName = computeErrorName(error)
359359

360-
let idx = unparsedStack.indexOf('react-stack-bottom-frame')
360+
let idx = unparsedStack.indexOf('react_stack_bottom_frame')
361361
if (idx !== -1) {
362362
idx = unparsedStack.lastIndexOf('\n', idx)
363+
} else {
364+
idx = unparsedStack.indexOf('react-stack-bottom-frame')
365+
if (idx !== -1) {
366+
idx = unparsedStack.lastIndexOf('\n', idx)
367+
}
363368
}
364369
if (idx !== -1 && !showIgnoreListed) {
365370
// Cut off everything after the bottom frame since it'll be React internals.

test/development/app-dir/owner-stack/owner-stack.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ function normalizeBrowserConsoleStackTrace(trace: unknown) {
1010
return (
1111
trace
1212
// Removes React's internals i.e. incomplete ignore-listing
13-
.split(/at react-stack-bottom-frame.*/m)[0]
13+
.split(
14+
/at (react-stack-bottom-frame|Object\.react_stack_bottom_frame).*/m
15+
)[0]
1416
// Remove the location `()` part in every line of stack trace;
1517
.replace(/\(.*\)/g, '')
1618
// Remove the leading spaces in every line of stack trace;

0 commit comments

Comments
 (0)