Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
81ab1ffc
Unverified
Commit
81ab1ffc
authored
Jun 03, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Jun 03, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev-overlay] Inject `isRecoverableError` implementation (#80003)
Same as with `get*Stack` implementation
parent
d14df6cc
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
40 additions
and
10 deletions
+40
-10
hot-reloader-client.tsx
.../components/react-dev-overlay/app/hot-reloader-client.tsx
+3
-1
hooks.ts
...xt/src/client/components/react-dev-overlay/pages/hooks.ts
+3
-1
shared.ts
...es/next/src/client/components/react-dev-overlay/shared.ts
+8
-1
error-overlay-nav.stories.tsx
...ts/errors/error-overlay-nav/error-overlay-nav.stories.tsx
+3
-0
error-overlay-pagination.stories.tsx
...r-overlay-pagination/error-overlay-pagination.stories.tsx
+5
-1
errors.stories.tsx
...ponents/react-dev-overlay/ui/container/errors.stories.tsx
+5
-0
errors.tsx
...ient/components/react-dev-overlay/ui/container/errors.tsx
+7
-6
render-error.tsx
...t-dev-overlay/ui/container/runtime-error/render-error.tsx
+1
-0
dev-overlay.stories.tsx
...t/components/react-dev-overlay/ui/dev-overlay.stories.tsx
+3
-0
get-error-by-type.ts
...t/components/react-dev-overlay/utils/get-error-by-type.ts
+2
-0
No files found.
packages/next/src/client/components/react-dev-overlay/app/hot-reloader-client.tsx
View file @
81ab1ffc
...
@@ -45,6 +45,7 @@ import reportHmrLatency from '../utils/report-hmr-latency'
...
@@ -45,6 +45,7 @@ import reportHmrLatency from '../utils/report-hmr-latency'
import
{
TurbopackHmr
}
from
'../utils/turbopack-hot-reloader-common'
import
{
TurbopackHmr
}
from
'../utils/turbopack-hot-reloader-common'
import
{
NEXT_HMR_REFRESH_HASH_COOKIE
}
from
'../../app-router-headers'
import
{
NEXT_HMR_REFRESH_HASH_COOKIE
}
from
'../../app-router-headers'
import
{
getComponentStack
,
getOwnerStack
}
from
'../../errors/stitched-error'
import
{
getComponentStack
,
getOwnerStack
}
from
'../../errors/stitched-error'
import
{
isRecoverableError
}
from
'../../../react-client-callbacks/on-recoverable-error'
export
interface
Dispatcher
{
export
interface
Dispatcher
{
onBuildOk
():
void
onBuildOk
():
void
...
@@ -483,7 +484,8 @@ export default function HotReload({
...
@@ -483,7 +484,8 @@ export default function HotReload({
const
[
state
,
dispatch
]
=
useErrorOverlayReducer
(
const
[
state
,
dispatch
]
=
useErrorOverlayReducer
(
'app'
,
'app'
,
getComponentStack
,
getComponentStack
,
getOwnerStack
getOwnerStack
,
isRecoverableError
)
)
const
dispatcher
=
useMemo
<
Dispatcher
>
(()
=>
{
const
dispatcher
=
useMemo
<
Dispatcher
>
(()
=>
{
...
...
packages/next/src/client/components/react-dev-overlay/pages/hooks.ts
View file @
81ab1ffc
...
@@ -3,12 +3,14 @@ import * as Bus from './bus'
...
@@ -3,12 +3,14 @@ import * as Bus from './bus'
import
{
useErrorOverlayReducer
}
from
'../shared'
import
{
useErrorOverlayReducer
}
from
'../shared'
import
{
Router
}
from
'../../../router'
import
{
Router
}
from
'../../../router'
import
{
getComponentStack
,
getOwnerStack
}
from
'../../errors/stitched-error'
import
{
getComponentStack
,
getOwnerStack
}
from
'../../errors/stitched-error'
import
{
isRecoverableError
}
from
'../../../react-client-callbacks/on-recoverable-error'
export
const
usePagesDevOverlay
=
()
=>
{
export
const
usePagesDevOverlay
=
()
=>
{
const
[
state
,
dispatch
]
=
useErrorOverlayReducer
(
const
[
state
,
dispatch
]
=
useErrorOverlayReducer
(
'pages'
,
'pages'
,
getComponentStack
,
getComponentStack
,
getOwnerStack
getOwnerStack
,
isRecoverableError
)
)
React
.
useEffect
(()
=>
{
React
.
useEffect
(()
=>
{
...
...
packages/next/src/client/components/react-dev-overlay/shared.ts
View file @
81ab1ffc
...
@@ -7,6 +7,7 @@ import type { DebugInfo } from './types'
...
@@ -7,6 +7,7 @@ import type { DebugInfo } from './types'
import
type
{
DevIndicatorServerState
}
from
'../../../server/dev/dev-indicator-server-state'
import
type
{
DevIndicatorServerState
}
from
'../../../server/dev/dev-indicator-server-state'
import
type
{
HMR_ACTION_TYPES
}
from
'../../../server/dev/hot-reloader-types'
import
type
{
HMR_ACTION_TYPES
}
from
'../../../server/dev/hot-reloader-types'
import
{
parseStack
}
from
'./utils/parse-stack'
import
{
parseStack
}
from
'./utils/parse-stack'
import
{
isConsoleError
}
from
'../errors/console-error'
type
FastRefreshState
=
type
FastRefreshState
=
/** No refresh in progress. */
/** No refresh in progress. */
...
@@ -169,7 +170,8 @@ function getInitialState(
...
@@ -169,7 +170,8 @@ function getInitialState(
export
function
useErrorOverlayReducer
(
export
function
useErrorOverlayReducer
(
routerType
:
'pages'
|
'app'
,
routerType
:
'pages'
|
'app'
,
getComponentStack
:
(
error
:
Error
)
=>
string
|
undefined
,
getComponentStack
:
(
error
:
Error
)
=>
string
|
undefined
,
getOwnerStack
:
(
error
:
Error
)
=>
string
|
null
|
undefined
getOwnerStack
:
(
error
:
Error
)
=>
string
|
null
|
undefined
,
isRecoverableError
:
(
error
:
Error
)
=>
boolean
)
{
)
{
function
pushErrorFilterDuplicates
(
function
pushErrorFilterDuplicates
(
events
:
SupportedErrorEvent
[],
events
:
SupportedErrorEvent
[],
...
@@ -188,6 +190,11 @@ export function useErrorOverlayReducer(
...
@@ -188,6 +190,11 @@ export function useErrorOverlayReducer(
error
,
error
,
frames
,
frames
,
componentStackFrames
,
componentStackFrames
,
type
:
isRecoverableError
(
error
)
?
'recoverable'
:
isConsoleError
(
error
)
?
'console'
:
'runtime'
,
}
}
const
pendingEvents
=
events
.
filter
((
event
)
=>
{
const
pendingEvents
=
events
.
filter
((
event
)
=>
{
// Filter out duplicate errors
// Filter out duplicate errors
...
...
packages/next/src/client/components/react-dev-overlay/ui/components/errors/error-overlay-nav/error-overlay-nav.stories.tsx
View file @
81ab1ffc
...
@@ -21,18 +21,21 @@ export const Default: Story = {
...
@@ -21,18 +21,21 @@ export const Default: Story = {
runtime
:
true
,
runtime
:
true
,
error
:
new
Error
(
'First error message'
),
error
:
new
Error
(
'First error message'
),
frames
:
()
=>
Promise
.
resolve
([]),
frames
:
()
=>
Promise
.
resolve
([]),
type
:
'runtime'
,
},
},
{
{
id
:
1
,
id
:
1
,
runtime
:
true
,
runtime
:
true
,
error
:
new
Error
(
'Second error message'
),
error
:
new
Error
(
'Second error message'
),
frames
:
()
=>
Promise
.
resolve
([]),
frames
:
()
=>
Promise
.
resolve
([]),
type
:
'runtime'
,
},
},
{
{
id
:
2
,
id
:
2
,
runtime
:
true
,
runtime
:
true
,
error
:
new
Error
(
'Third error message'
),
error
:
new
Error
(
'Third error message'
),
frames
:
()
=>
Promise
.
resolve
([]),
frames
:
()
=>
Promise
.
resolve
([]),
type
:
'runtime'
,
},
},
],
],
activeIdx
:
1
,
activeIdx
:
1
,
...
...
packages/next/src/client/components/react-dev-overlay/ui/components/errors/error-overlay-pagination/error-overlay-pagination.stories.tsx
View file @
81ab1ffc
...
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react'
...
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react'
import
{
ErrorOverlayPagination
}
from
'./error-overlay-pagination'
import
{
ErrorOverlayPagination
}
from
'./error-overlay-pagination'
import
{
withShadowPortal
}
from
'../../../storybook/with-shadow-portal'
import
{
withShadowPortal
}
from
'../../../storybook/with-shadow-portal'
import
{
useState
}
from
'react'
import
{
useState
}
from
'react'
import
type
{
ReadyRuntimeError
}
from
'../../../../utils/get-error-by-type'
const
meta
:
Meta
<
typeof
ErrorOverlayPagination
>
=
{
const
meta
:
Meta
<
typeof
ErrorOverlayPagination
>
=
{
component
:
ErrorOverlayPagination
,
component
:
ErrorOverlayPagination
,
...
@@ -15,24 +16,27 @@ export default meta
...
@@ -15,24 +16,27 @@ export default meta
type
Story
=
StoryObj
<
typeof
ErrorOverlayPagination
>
type
Story
=
StoryObj
<
typeof
ErrorOverlayPagination
>
// Mock errors for stories
// Mock errors for stories
const
mockErrors
=
[
const
mockErrors
:
ReadyRuntimeError
[]
=
[
{
{
id
:
1
,
id
:
1
,
runtime
:
true
as
const
,
runtime
:
true
as
const
,
error
:
new
Error
(
'First error'
),
error
:
new
Error
(
'First error'
),
frames
:
()
=>
Promise
.
resolve
([]),
frames
:
()
=>
Promise
.
resolve
([]),
type
:
'runtime'
,
},
},
{
{
id
:
2
,
id
:
2
,
runtime
:
true
as
const
,
runtime
:
true
as
const
,
error
:
new
Error
(
'Second error'
),
error
:
new
Error
(
'Second error'
),
frames
:
()
=>
Promise
.
resolve
([]),
frames
:
()
=>
Promise
.
resolve
([]),
type
:
'runtime'
,
},
},
{
{
id
:
3
,
id
:
3
,
runtime
:
true
as
const
,
runtime
:
true
as
const
,
error
:
new
Error
(
'Third error'
),
error
:
new
Error
(
'Third error'
),
frames
:
()
=>
Promise
.
resolve
([]),
frames
:
()
=>
Promise
.
resolve
([]),
type
:
'runtime'
,
},
},
]
]
...
...
packages/next/src/client/components/react-dev-overlay/ui/container/errors.stories.tsx
View file @
81ab1ffc
...
@@ -96,6 +96,7 @@ const runtimeErrors: ReadyRuntimeError[] = [
...
@@ -96,6 +96,7 @@ const runtimeErrors: ReadyRuntimeError[] = [
},
},
...
Array
(
20
).
fill
(
ignoredFrame
),
...
Array
(
20
).
fill
(
ignoredFrame
),
]),
]),
type
:
'runtime'
,
},
},
{
{
id
:
2
,
id
:
2
,
...
@@ -113,6 +114,7 @@ const runtimeErrors: ReadyRuntimeError[] = [
...
@@ -113,6 +114,7 @@ const runtimeErrors: ReadyRuntimeError[] = [
originalCodeFrame
:
originalCodeFrame
(
'Second error message'
),
originalCodeFrame
:
originalCodeFrame
(
'Second error message'
),
},
},
]),
]),
type
:
'runtime'
,
},
},
{
{
id
:
3
,
id
:
3
,
...
@@ -130,6 +132,7 @@ const runtimeErrors: ReadyRuntimeError[] = [
...
@@ -130,6 +132,7 @@ const runtimeErrors: ReadyRuntimeError[] = [
originalCodeFrame
:
originalCodeFrame
(
'Third error message'
),
originalCodeFrame
:
originalCodeFrame
(
'Third error message'
),
},
},
]),
]),
type
:
'runtime'
,
},
},
{
{
id
:
4
,
id
:
4
,
...
@@ -147,6 +150,7 @@ const runtimeErrors: ReadyRuntimeError[] = [
...
@@ -147,6 +150,7 @@ const runtimeErrors: ReadyRuntimeError[] = [
originalCodeFrame
:
originalCodeFrame
(
'typeof window !== undefined'
),
originalCodeFrame
:
originalCodeFrame
(
'typeof window !== undefined'
),
},
},
]),
]),
type
:
'runtime'
,
},
},
]
]
...
@@ -232,6 +236,7 @@ export const WithHydrationWarning: Story = {
...
@@ -232,6 +236,7 @@ export const WithHydrationWarning: Story = {
},
},
},
},
]),
]),
type
:
'runtime'
,
},
},
],
],
debugInfo
:
{
devtoolsFrontendUrl
:
undefined
},
debugInfo
:
{
devtoolsFrontendUrl
:
undefined
},
...
...
packages/next/src/client/components/react-dev-overlay/ui/container/errors.tsx
View file @
81ab1ffc
...
@@ -5,7 +5,6 @@ import { RuntimeError } from './runtime-error'
...
@@ -5,7 +5,6 @@ import { RuntimeError } from './runtime-error'
import
{
getErrorSource
}
from
'../../../../../shared/lib/error-source'
import
{
getErrorSource
}
from
'../../../../../shared/lib/error-source'
import
{
HotlinkedText
}
from
'../components/hot-linked-text'
import
{
HotlinkedText
}
from
'../components/hot-linked-text'
import
{
PseudoHtmlDiff
}
from
'./runtime-error/component-stack-pseudo-html'
import
{
PseudoHtmlDiff
}
from
'./runtime-error/component-stack-pseudo-html'
import
{
isConsoleError
}
from
'../../../errors/console-error'
import
{
extractNextErrorCode
}
from
'../../../../../lib/error-telemetry-utils'
import
{
extractNextErrorCode
}
from
'../../../../../lib/error-telemetry-utils'
import
{
import
{
ErrorOverlayLayout
,
ErrorOverlayLayout
,
...
@@ -19,7 +18,6 @@ import {
...
@@ -19,7 +18,6 @@ import {
import
type
{
ReadyRuntimeError
}
from
'../../utils/get-error-by-type'
import
type
{
ReadyRuntimeError
}
from
'../../utils/get-error-by-type'
import
type
{
ErrorBaseProps
}
from
'../components/errors/error-overlay/error-overlay'
import
type
{
ErrorBaseProps
}
from
'../components/errors/error-overlay/error-overlay'
import
{
getSquashedHydrationErrorDetails
}
from
'../../pages/hydration-error-state'
import
{
getSquashedHydrationErrorDetails
}
from
'../../pages/hydration-error-state'
import
{
isRecoverableError
}
from
'../../../../react-client-callbacks/on-recoverable-error'
export
interface
ErrorsProps
extends
ErrorBaseProps
{
export
interface
ErrorsProps
extends
ErrorBaseProps
{
runtimeErrors
:
ReadyRuntimeError
[]
runtimeErrors
:
ReadyRuntimeError
[]
...
@@ -56,11 +54,14 @@ function GenericErrorDescription({ error }: { error: Error }) {
...
@@ -56,11 +54,14 @@ function GenericErrorDescription({ error }: { error: Error }) {
)
)
}
}
function
getErrorType
(
error
:
Error
):
ErrorOverlayLayoutProps
[
'errorType'
]
{
function
getErrorTypeLabel
(
if
(
isRecoverableError
(
error
))
{
error
:
Error
,
type
:
ReadyRuntimeError
[
'type'
]
):
ErrorOverlayLayoutProps
[
'errorType'
]
{
if
(
type
===
'recoverable'
)
{
return
`Recoverable
${
error
.
name
}
`
return
`Recoverable
${
error
.
name
}
`
}
}
if
(
isConsoleError
(
error
)
)
{
if
(
type
===
'console'
)
{
return
`Console
${
error
.
name
}
`
return
`Console
${
error
.
name
}
`
}
}
return
`Runtime
${
error
.
name
}
`
return
`Runtime
${
error
.
name
}
`
...
@@ -141,7 +142,7 @@ export function Errors({
...
@@ -141,7 +142,7 @@ export function Errors({
const
isServerError
=
[
'server'
,
'edge-server'
].
includes
(
const
isServerError
=
[
'server'
,
'edge-server'
].
includes
(
getErrorSource
(
error
)
||
''
getErrorSource
(
error
)
||
''
)
)
const
errorType
=
getErrorType
(
error
)
const
errorType
=
getErrorType
Label
(
error
,
activeError
.
type
)
// TOOD: May be better to always treat everything past the first blank line as notes
// TOOD: May be better to always treat everything past the first blank line as notes
// We're currently only special casing hydration error messages.
// We're currently only special casing hydration error messages.
const
notes
=
errorDetails
.
notes
const
notes
=
errorDetails
.
notes
...
...
packages/next/src/client/components/react-dev-overlay/ui/container/runtime-error/render-error.tsx
View file @
81ab1ffc
...
@@ -13,6 +13,7 @@ export type SupportedErrorEvent = {
...
@@ -13,6 +13,7 @@ export type SupportedErrorEvent = {
error
:
Error
error
:
Error
frames
:
StackFrame
[]
frames
:
StackFrame
[]
componentStackFrames
?:
ComponentStackFrame
[]
componentStackFrames
?:
ComponentStackFrame
[]
type
:
'runtime'
|
'recoverable'
|
'console'
}
}
type
Props
=
{
type
Props
=
{
...
...
packages/next/src/client/components/react-dev-overlay/ui/dev-overlay.stories.tsx
View file @
81ab1ffc
...
@@ -52,6 +52,7 @@ const initialState: OverlayState = {
...
@@ -52,6 +52,7 @@ const initialState: OverlayState = {
column
:
5
,
column
:
5
,
},
},
],
],
type
:
'runtime'
,
},
},
{
{
id
:
2
,
id
:
2
,
...
@@ -59,6 +60,7 @@ const initialState: OverlayState = {
...
@@ -59,6 +60,7 @@ const initialState: OverlayState = {
__NEXT_ERROR_CODE
:
'E002'
,
__NEXT_ERROR_CODE
:
'E002'
,
}),
}),
frames
:
[],
frames
:
[],
type
:
'runtime'
,
},
},
{
{
id
:
3
,
id
:
3
,
...
@@ -66,6 +68,7 @@ const initialState: OverlayState = {
...
@@ -66,6 +68,7 @@ const initialState: OverlayState = {
__NEXT_ERROR_CODE
:
'E003'
,
__NEXT_ERROR_CODE
:
'E003'
,
}),
}),
frames
:
[],
frames
:
[],
type
:
'runtime'
,
},
},
],
],
refreshState
:
{
type
:
'idle'
},
refreshState
:
{
type
:
'idle'
},
...
...
packages/next/src/client/components/react-dev-overlay/utils/get-error-by-type.ts
View file @
81ab1ffc
...
@@ -11,6 +11,7 @@ export type ReadyRuntimeError = {
...
@@ -11,6 +11,7 @@ export type ReadyRuntimeError = {
error
:
Error
&
{
environmentName
?:
string
}
error
:
Error
&
{
environmentName
?:
string
}
frames
:
OriginalStackFrame
[]
|
(()
=>
Promise
<
OriginalStackFrame
[]
>
)
frames
:
OriginalStackFrame
[]
|
(()
=>
Promise
<
OriginalStackFrame
[]
>
)
componentStackFrames
?:
ComponentStackFrame
[]
componentStackFrames
?:
ComponentStackFrame
[]
type
:
'runtime'
|
'console'
|
'recoverable'
}
}
export
const
useFrames
=
(
error
:
ReadyRuntimeError
):
OriginalStackFrame
[]
=>
{
export
const
useFrames
=
(
error
:
ReadyRuntimeError
):
OriginalStackFrame
[]
=>
{
...
@@ -43,6 +44,7 @@ export async function getErrorByType(
...
@@ -43,6 +44,7 @@ export async function getErrorByType(
id
:
event
.
id
,
id
:
event
.
id
,
runtime
:
true
,
runtime
:
true
,
error
:
event
.
error
,
error
:
event
.
error
,
type
:
event
.
type
,
}
as
const
}
as
const
if
(
'use'
in
React
)
{
if
(
'use'
in
React
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment