Skip to content

Commit 86f38f3

Browse files
committed
[dev-overlay] Stop grouping callstack frames into ignored vs. not ignored
1 parent 22812d4 commit 86f38f3

File tree

3 files changed

+12
-41
lines changed

3 files changed

+12
-41
lines changed

packages/next/src/client/components/react-dev-overlay/ui/components/errors/call-stack/call-stack.stories.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export const MultipleFrames: Story = {
6262
lineNumber: 5,
6363
},
6464
},
65+
...Array(5).fill(ignoredFrame),
6566
{
6667
...frame,
6768
originalStackFrame: {

packages/next/src/client/components/react-dev-overlay/ui/components/errors/call-stack/call-stack.tsx

+9-39
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,8 @@ export function CallStack({ frames, dialogResizerRef }: CallStackProps) {
1111
const initialDialogHeight = useRef<number>(NaN)
1212
const [isIgnoreListOpen, setIsIgnoreListOpen] = useState(false)
1313

14-
const { visibleFrames, ignoredFrames, ignoreListLength } = useMemo(() => {
15-
const visible: OriginalStackFrame[] = []
16-
const ignored: OriginalStackFrame[] = []
17-
18-
for (const frame of frames) {
19-
if (!frame.ignored) {
20-
visible.push(frame)
21-
}
22-
if (frame.ignored) {
23-
ignored.push(frame)
24-
}
25-
}
26-
27-
return {
28-
visibleFrames: visible,
29-
ignoredFrames: ignored,
30-
ignoreListLength: ignored.length,
31-
}
14+
const ignoredFramesTally = useMemo(() => {
15+
return frames.reduce((tally, frame) => tally + (frame.ignored ? 1 : 0), 0)
3216
}, [frames])
3317

3418
function onToggleIgnoreList() {
@@ -65,36 +49,22 @@ export function CallStack({ frames, dialogResizerRef }: CallStackProps) {
6549
{frames.length}
6650
</span>
6751
</p>
68-
{ignoreListLength > 0 && (
52+
{ignoredFramesTally > 0 && (
6953
<button
7054
data-expand-ignore-button={isIgnoreListOpen}
7155
className="error-overlay-call-stack-ignored-list-toggle-button"
7256
onClick={onToggleIgnoreList}
7357
>
74-
{`${isIgnoreListOpen ? 'Hide' : 'Show'} ${ignoreListLength} ignore-listed frames`}
58+
{`${isIgnoreListOpen ? 'Hide' : 'Show'} ${ignoredFramesTally} ignore-listed frame(s)`}
7559
<ChevronUpDown />
7660
</button>
7761
)}
7862
</div>
79-
{visibleFrames.map((frame, frameIndex) => (
80-
<CallStackFrame
81-
key={`call-stack-leading-${frameIndex}`}
82-
frame={frame}
83-
index={frameIndex}
84-
/>
85-
))}
86-
87-
{isIgnoreListOpen && (
88-
<>
89-
{ignoredFrames.map((frame, frameIndex) => (
90-
<CallStackFrame
91-
key={`call-stack-ignored-${frameIndex}`}
92-
frame={frame}
93-
index={frameIndex}
94-
/>
95-
))}
96-
</>
97-
)}
63+
{frames.map((frame, frameIndex) => {
64+
return !frame.ignored || isIgnoreListOpen ? (
65+
<CallStackFrame key={frameIndex} frame={frame} index={frameIndex} />
66+
) : null
67+
})}
9868
</div>
9969
)
10070
}

test/development/app-dir/error-overlay/error-ignored-frames/error-ignored-frames.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ describe('error-ignored-frames', () => {
9999
if (isTurbopack) {
100100
expect(expendedStack).toMatchInlineSnapshot(`
101101
"at <unknown> (app/interleaved/page.tsx (7:11))
102-
at Page (app/interleaved/page.tsx (6:35))
103102
at invokeCallback ()
103+
at Page (app/interleaved/page.tsx (6:35))
104104
at ClientPageRoot ()"
105105
`)
106106
} else {
107107
expect(expendedStack).toMatchInlineSnapshot(`
108108
"at eval (app/interleaved/page.tsx (7:11))
109-
at Page (app/interleaved/page.tsx (6:36))
110109
at invokeCallback (node_modules/interleave/index.js (2:1))
110+
at Page (app/interleaved/page.tsx (6:36))
111111
at ClientPageRoot (../src/client/components/client-page.tsx (60:12))"
112112
`)
113113
}

0 commit comments

Comments
 (0)