Skip to content

Commit b2c751f

Browse files
authored
[devtools] Remove unused componentStackFrames field (#82395)
1 parent 333489d commit b2c751f

File tree

15 files changed

+12
-206
lines changed

15 files changed

+12
-206
lines changed

packages/next/src/client/app-next-dev.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import './app-webpack'
44

55
import { renderAppDevOverlay } from 'next/dist/compiled/next-devtools'
66
import { appBootstrap } from './app-bootstrap'
7-
import {
8-
getComponentStack,
9-
getOwnerStack,
10-
} from '../next-devtools/userspace/app/errors/stitched-error'
7+
import { getOwnerStack } from '../next-devtools/userspace/app/errors/stitched-error'
118
import { isRecoverableError } from './react-client-callbacks/on-recoverable-error'
129

1310
// eslint-disable-next-line @next/internal/typechecked-require
@@ -18,6 +15,6 @@ appBootstrap(() => {
1815
try {
1916
hydrate(instrumentationHooks)
2017
} finally {
21-
renderAppDevOverlay(getComponentStack, getOwnerStack, isRecoverableError)
18+
renderAppDevOverlay(getOwnerStack, isRecoverableError)
2219
}
2320
})

packages/next/src/client/app-next-turbopack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ appBootstrap(() => {
1313
hydrate(instrumentationHooks)
1414
} finally {
1515
if (process.env.NODE_ENV !== 'production') {
16-
const { getComponentStack, getOwnerStack } =
16+
const { getOwnerStack } =
1717
require('../next-devtools/userspace/app/errors/stitched-error') as typeof import('../next-devtools/userspace/app/errors/stitched-error')
1818
const { renderAppDevOverlay } =
1919
require('next/dist/compiled/next-devtools') as typeof import('next/dist/compiled/next-devtools')
20-
renderAppDevOverlay(getComponentStack, getOwnerStack, isRecoverableError)
20+
renderAppDevOverlay(getOwnerStack, isRecoverableError)
2121
}
2222
}
2323
})

packages/next/src/client/react-client-callbacks/error-boundary-callbacks.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function onCaughtError(
5454
// We don't consider errors caught unless they're caught by an explicit error
5555
// boundary. The built-in ones are considered implicit.
5656
// This mimics how the same app would behave without Next.js.
57-
return onUncaughtError(thrownValue, errorInfo)
57+
return onUncaughtError(thrownValue)
5858
}
5959

6060
// Skip certain custom errors which are not expected to be reported on client
@@ -84,7 +84,7 @@ export function onCaughtError(
8484
: `The above error occurred in one of your components.`
8585

8686
const errorLocation = `${componentErrorMessage} ${errorBoundaryMessage}`
87-
const error = devToolErrorMod.decorateDevError(thrownValue, errorInfo)
87+
const error = devToolErrorMod.decorateDevError(thrownValue)
8888

8989
// Log and report the error with location but without modifying the error stack
9090
devToolErrorMod.originConsoleError('%o\n\n%s', thrownValue, errorLocation)
@@ -95,15 +95,12 @@ export function onCaughtError(
9595
}
9696
}
9797

98-
export function onUncaughtError(
99-
thrownValue: unknown,
100-
errorInfo: React.ErrorInfo
101-
) {
98+
export function onUncaughtError(thrownValue: unknown) {
10299
// Skip certain custom errors which are not expected to be reported on client
103100
if (isBailoutToCSRError(thrownValue) || isNextRouterError(thrownValue)) return
104101

105102
if (process.env.NODE_ENV !== 'production') {
106-
const error = devToolErrorMod.decorateDevError(thrownValue, errorInfo)
103+
const error = devToolErrorMod.decorateDevError(thrownValue)
107104

108105
// TODO: Add an adendum to the overlay telling people about custom error boundaries.
109106
reportGlobalError(error)

packages/next/src/client/react-client-callbacks/on-recoverable-error.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ export function isRecoverableError(error: Error): boolean {
1212
}
1313

1414
export const onRecoverableError: HydrationOptions['onRecoverableError'] = (
15-
error,
16-
errorInfo
15+
error
1716
) => {
1817
// x-ref: https://github.com/facebook/react/pull/28736
1918
let cause = isError(error) && 'cause' in error ? error.cause : error
@@ -23,7 +22,7 @@ export const onRecoverableError: HydrationOptions['onRecoverableError'] = (
2322
if (process.env.NODE_ENV !== 'production') {
2423
const { decorateDevError } =
2524
require('../../next-devtools/userspace/app/errors/stitched-error') as typeof import('../../next-devtools/userspace/app/errors/stitched-error')
26-
const causeError = decorateDevError(cause, errorInfo)
25+
const causeError = decorateDevError(cause)
2726
recoverableErrors.add(causeError)
2827
cause = causeError
2928
}

packages/next/src/next-devtools/dev-overlay.browser.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,18 @@ function replayQueuedEvents(dispatch: NonNullable<typeof maybeDispatch>) {
185185
}
186186

187187
function DevOverlayRoot({
188-
getComponentStack,
189188
getOwnerStack,
190189
getSquashedHydrationErrorDetails,
191190
isRecoverableError,
192191
routerType,
193192
}: {
194-
getComponentStack: (error: Error) => string | undefined
195193
getOwnerStack: (error: Error) => string | null | undefined
196194
getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null
197195
isRecoverableError: (error: Error) => boolean
198196
routerType: 'app' | 'pages'
199197
}) {
200198
const [state, dispatch] = useErrorOverlayReducer(
201199
routerType,
202-
getComponentStack,
203200
getOwnerStack,
204201
isRecoverableError
205202
)
@@ -254,7 +251,6 @@ function getSquashedHydrationErrorDetailsApp() {
254251
}
255252

256253
export function renderAppDevOverlay(
257-
getComponentStack: (error: Error) => string | undefined,
258254
getOwnerStack: (error: Error) => string | null | undefined,
259255
isRecoverableError: (error: Error) => boolean
260256
): void {
@@ -293,7 +289,6 @@ export function renderAppDevOverlay(
293289
// At least it won't unmount any user code if it errors.
294290
root.render(
295291
<DevOverlayRoot
296-
getComponentStack={getComponentStack}
297292
getOwnerStack={getOwnerStack}
298293
getSquashedHydrationErrorDetails={getSquashedHydrationErrorDetailsApp}
299294
isRecoverableError={isRecoverableError}
@@ -307,7 +302,6 @@ export function renderAppDevOverlay(
307302
}
308303

309304
export function renderPagesDevOverlay(
310-
getComponentStack: (error: Error) => string | undefined,
311305
getOwnerStack: (error: Error) => string | null | undefined,
312306
getSquashedHydrationErrorDetails: (
313307
error: Error
@@ -357,7 +351,6 @@ export function renderPagesDevOverlay(
357351
// At least it won't unmount any user code if it errors.
358352
root.render(
359353
<DevOverlayRoot
360-
getComponentStack={getComponentStack}
361354
getOwnerStack={getOwnerStack}
362355
getSquashedHydrationErrorDetails={getSquashedHydrationErrorDetails}
363356
isRecoverableError={isRecoverableError}

packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-nav/error-overlay-nav.stories.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,20 @@ export const Default: Story = {
2121
runtime: true,
2222
error: new Error('First error message'),
2323
frames: () => Promise.resolve([]),
24-
componentStackFrames: undefined,
2524
type: 'runtime',
2625
},
2726
{
2827
id: 1,
2928
runtime: true,
3029
error: new Error('Second error message'),
3130
frames: () => Promise.resolve([]),
32-
componentStackFrames: undefined,
3331
type: 'runtime',
3432
},
3533
{
3634
id: 2,
3735
runtime: true,
3836
error: new Error('Third error message'),
3937
frames: () => Promise.resolve([]),
40-
componentStackFrames: undefined,
4138
type: 'runtime',
4239
},
4340
],

packages/next/src/next-devtools/dev-overlay/components/errors/error-overlay-pagination/error-overlay-pagination.stories.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,20 @@ const mockErrors: ReadyRuntimeError[] = [
2222
runtime: true as const,
2323
error: new Error('First error'),
2424
frames: () => Promise.resolve([]),
25-
componentStackFrames: undefined,
2625
type: 'runtime',
2726
},
2827
{
2928
id: 2,
3029
runtime: true as const,
3130
error: new Error('Second error'),
3231
frames: () => Promise.resolve([]),
33-
componentStackFrames: undefined,
3432
type: 'runtime',
3533
},
3634
{
3735
id: 3,
3836
runtime: true as const,
3937
error: new Error('Third error'),
4038
frames: () => Promise.resolve([]),
41-
componentStackFrames: undefined,
4239
type: 'runtime',
4340
},
4441
]

packages/next/src/next-devtools/dev-overlay/container/errors.stories.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,6 @@ export const WithHydrationWarning: Story = {
8989
},
9090
},
9191
]),
92-
componentStackFrames: [
93-
{
94-
component: 'MyComponent',
95-
file: 'app/page.tsx',
96-
line1: 10,
97-
column1: 5,
98-
canOpenInEditor: true,
99-
},
100-
{
101-
component: 'ParentComponent',
102-
file: 'app/layout.tsx',
103-
line1: 20,
104-
column1: 3,
105-
canOpenInEditor: true,
106-
},
107-
],
10892
type: 'runtime',
10993
},
11094
],

packages/next/src/next-devtools/dev-overlay/container/runtime-error/render-error.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ import {
66
getErrorByType,
77
type ReadyRuntimeError,
88
} from '../../utils/get-error-by-type'
9-
import type { ComponentStackFrame } from '../../utils/parse-component-stack'
109
import { usePersistentCacheErrorDetection } from '../../components/errors/error-overlay-toolbar/restart-server-button'
1110

1211
export type SupportedErrorEvent = {
1312
id: number
1413
error: Error
1514
frames: readonly StackFrame[]
16-
componentStackFrames?: readonly ComponentStackFrame[]
1715
type: 'runtime' | 'recoverable' | 'console'
1816
}
1917

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useReducer } from 'react'
22

33
import type { VersionInfo } from '../../server/dev/parse-version-info'
44
import type { SupportedErrorEvent } from './container/runtime-error/render-error'
5-
import { parseComponentStack } from './utils/parse-component-stack'
65
import type { DebugInfo } from '../shared/types'
76
import type { DevIndicatorServerState } from '../../server/dev/dev-indicator-server-state'
87
import { parseStack } from '../../server/lib/parse-stack'
@@ -319,7 +318,6 @@ function getInitialState(
319318

320319
export function useErrorOverlayReducer(
321320
routerType: 'pages' | 'app',
322-
getComponentStack: (error: Error) => string | undefined,
323321
getOwnerStack: (error: Error) => string | null | undefined,
324322
isRecoverableError: (error: Error) => boolean
325323
) {
@@ -328,18 +326,12 @@ export function useErrorOverlayReducer(
328326
id: number,
329327
error: Error
330328
): readonly SupportedErrorEvent[] {
331-
const componentStack = getComponentStack(error)
332-
const componentStackFrames =
333-
componentStack === undefined
334-
? undefined
335-
: parseComponentStack(componentStack)
336329
const ownerStack = getOwnerStack(error)
337330
const frames = parseStack((error.stack || '') + (ownerStack || ''))
338331
const pendingEvent: SupportedErrorEvent = {
339332
id,
340333
error,
341334
frames,
342-
componentStackFrames,
343335
type: isRecoverableError(error)
344336
? 'recoverable'
345337
: isConsoleError(error)

0 commit comments

Comments
 (0)