Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dev-overlay] Stop grouping callstack frames into ignored vs. not ignored #76861

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const MultipleFrames: Story = {
lineNumber: 5,
},
},
...Array(5).fill(ignoredFrame),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to show a more realistic stacktrace where ignored and not-ignored frames are interleaved.

{
...frame,
originalStackFrame: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,8 @@ export function CallStack({ frames, dialogResizerRef }: CallStackProps) {
const initialDialogHeight = useRef<number>(NaN)
const [isIgnoreListOpen, setIsIgnoreListOpen] = useState(false)

const { visibleFrames, ignoredFrames, ignoreListLength } = useMemo(() => {
const visible: OriginalStackFrame[] = []
const ignored: OriginalStackFrame[] = []

for (const frame of frames) {
if (!frame.ignored) {
visible.push(frame)
}
if (frame.ignored) {
ignored.push(frame)
}
}

return {
visibleFrames: visible,
ignoredFrames: ignored,
ignoreListLength: ignored.length,
}
const ignoredFramesTally = useMemo(() => {
return frames.reduce((tally, frame) => tally + (frame.ignored ? 1 : 0), 0)
}, [frames])

function onToggleIgnoreList() {
Expand Down Expand Up @@ -65,36 +49,22 @@ export function CallStack({ frames, dialogResizerRef }: CallStackProps) {
{frames.length}
</span>
</p>
{ignoreListLength > 0 && (
{ignoredFramesTally > 0 && (
<button
data-expand-ignore-button={isIgnoreListOpen}
className="error-overlay-call-stack-ignored-list-toggle-button"
onClick={onToggleIgnoreList}
>
{`${isIgnoreListOpen ? 'Hide' : 'Show'} ${ignoreListLength} ignore-listed frames`}
{`${isIgnoreListOpen ? 'Hide' : 'Show'} ${ignoredFramesTally} ignore-listed frame(s)`}
<ChevronUpDown />
</button>
)}
</div>
{visibleFrames.map((frame, frameIndex) => (
<CallStackFrame
key={`call-stack-leading-${frameIndex}`}
frame={frame}
index={frameIndex}
/>
))}

{isIgnoreListOpen && (
<>
{ignoredFrames.map((frame, frameIndex) => (
<CallStackFrame
key={`call-stack-ignored-${frameIndex}`}
frame={frame}
index={frameIndex}
/>
))}
</>
)}
{frames.map((frame, frameIndex) => {
return !frame.ignored || isIgnoreListOpen ? (
<CallStackFrame key={frameIndex} frame={frame} index={frameIndex} />
) : null
})}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ describe('error-ignored-frames', () => {
if (isTurbopack) {
expect(expendedStack).toMatchInlineSnapshot(`
"at <unknown> (app/interleaved/page.tsx (7:11))
at Page (app/interleaved/page.tsx (6:35))
at invokeCallback ()
at Page (app/interleaved/page.tsx (6:35))
at ClientPageRoot ()"
`)
} else {
expect(expendedStack).toMatchInlineSnapshot(`
"at eval (app/interleaved/page.tsx (7:11))
at Page (app/interleaved/page.tsx (6:36))
at invokeCallback (node_modules/interleave/index.js (2:1))
at Page (app/interleaved/page.tsx (6:36))
at ClientPageRoot (../src/client/components/client-page.tsx (60:12))"
`)
}
Expand Down
Loading