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
717e54b0
Unverified
Commit
717e54b0
authored
Apr 10, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Apr 10, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev-overlay] Unify error deduplication logic (#78017)
parent
2a594945
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
44 deletions
+3
-44
enqueue-client-error.ts
...next/src/client/components/errors/enqueue-client-error.ts
+0
-12
use-error-handler.ts
...es/next/src/client/components/errors/use-error-handler.ts
+2
-3
render-error.tsx
...t-dev-overlay/ui/container/runtime-error/render-error.tsx
+1
-29
No files found.
packages/next/src/client/components/errors/enqueue-client-error.ts
deleted
100644 → 0
View file @
2a594945
// Dedupe the two consecutive errors: If the previous one is same as current one, ignore the current one.
export
function
enqueueConsecutiveDedupedError
(
queue
:
Array
<
Error
>
,
error
:
Error
)
{
const
previousError
=
queue
[
queue
.
length
-
1
]
// Compare the error stack to dedupe the consecutive errors
if
(
previousError
&&
previousError
.
stack
===
error
.
stack
)
{
return
}
queue
.
push
(
error
)
}
packages/next/src/client/components/errors/use-error-handler.ts
View file @
717e54b0
...
...
@@ -5,7 +5,6 @@ import { storeHydrationErrorStateFromConsoleArgs } from './hydration-error-info'
import
{
formatConsoleArgs
,
parseConsoleArgs
}
from
'../../lib/console'
import
isError
from
'../../../lib/is-error'
import
{
createConsoleError
}
from
'./console-error'
import
{
enqueueConsecutiveDedupedError
}
from
'./enqueue-client-error'
import
{
getReactStitchedError
}
from
'../errors/stitched-error'
const
queueMicroTask
=
...
...
@@ -37,7 +36,7 @@ export function handleConsoleError(
storeHydrationErrorStateFromConsoleArgs
(...
consoleErrorArgs
)
attachHydrationErrorState
(
error
)
e
nqueueConsecutiveDedupedError
(
errorQueue
,
error
)
e
rrorQueue
.
push
(
error
)
for
(
const
handler
of
errorHandlers
)
{
// Delayed the error being passed to React Dev Overlay,
// avoid the state being synchronously updated in the component.
...
...
@@ -60,7 +59,7 @@ export function handleClientError(originError: unknown) {
attachHydrationErrorState
(
error
)
e
nqueueConsecutiveDedupedError
(
errorQueue
,
error
)
e
rrorQueue
.
push
(
error
)
for
(
const
handler
of
errorHandlers
)
{
// Delayed the error being passed to React Dev Overlay,
// avoid the state being synchronously updated in the component.
...
...
packages/next/src/client/components/react-dev-overlay/ui/container/runtime-error/render-error.tsx
View file @
717e54b0
...
...
@@ -5,10 +5,6 @@ import type {
}
from
'../../../shared'
import
{
useMemo
,
useState
,
useEffect
}
from
'react'
import
{
ACTION_UNHANDLED_ERROR
,
ACTION_UNHANDLED_REJECTION
,
}
from
'../../../shared'
import
{
getErrorByType
,
type
ReadyRuntimeError
,
...
...
@@ -19,17 +15,6 @@ export type SupportedErrorEvent = {
event
:
UnhandledErrorAction
|
UnhandledRejectionAction
}
function
getErrorSignature
(
ev
:
SupportedErrorEvent
):
string
{
const
{
event
}
=
ev
// eslint-disable-next-line default-case -- TypeScript checks this
switch
(
event
.
type
)
{
case
ACTION_UNHANDLED_ERROR
:
case
ACTION_UNHANDLED_REJECTION
:
{
return
`
${
event
.
reason
.
name
}
::
${
event
.
reason
.
message
}
::
${
event
.
reason
.
stack
}
`
}
}
}
type
Props
=
{
children
:
(
params
:
{
runtimeErrors
:
ReadyRuntimeError
[]
...
...
@@ -72,14 +57,6 @@ const RenderRuntimeError = ({ children, state, isAppDir }: Props) => {
continue
}
// Check for duplicate errors
if
(
idx
>
0
)
{
const
prev
=
errors
[
idx
-
1
]
if
(
getErrorSignature
(
prev
)
===
getErrorSignature
(
e
))
{
continue
}
}
next
=
e
break
}
...
...
@@ -108,12 +85,7 @@ const RenderRuntimeError = ({ children, state, isAppDir }: Props) => {
}
},
[
nextError
,
isAppDir
])
const
totalErrorCount
=
errors
.
filter
((
err
,
idx
)
=>
{
const
prev
=
errors
[
idx
-
1
]
// Check for duplicates
if
(
idx
>
0
)
return
getErrorSignature
(
prev
)
!==
getErrorSignature
(
err
)
return
true
}).
length
const
totalErrorCount
=
errors
.
length
return
children
({
runtimeErrors
,
totalErrorCount
})
}
...
...
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