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
ec1fefca
Unverified
Commit
ec1fefca
authored
Feb 18, 2025
by
Jiachi Liu
Committed by
GitHub
Feb 18, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev-overlay] handle ssrd nextjs internal errors in overlay (#76124)
parent
473d47a6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
3 deletions
+47
-3
app-index.tsx
packages/next/src/client/app-index.tsx
+9
-0
app-render.tsx
packages/next/src/server/app-render/app-render.tsx
+1
-0
error-ignored-frames.test.ts
...overlay/error-ignored-frames/error-ignored-frames.test.ts
+3
-3
page.tsx
.../development/app-dir/ssr-only-error/app/notfound/page.tsx
+7
-0
ssr-only-error.test.ts
...development/app-dir/ssr-only-error/ssr-only-error.test.ts
+27
-0
No files found.
packages/next/src/client/app-index.tsx
View file @
ec1fefca
...
...
@@ -27,6 +27,7 @@ import { MissingSlotContext } from '../shared/lib/app-router-context.shared-runt
import
{
setAppBuildId
}
from
'./app-build-id'
import
{
shouldRenderRootLevelErrorOverlay
}
from
'./lib/is-error-thrown-while-rendering-rsc'
import
{
handleClientError
}
from
'./components/errors/use-error-handler'
import
{
isNextRouterError
}
from
'./components/is-next-router-error'
/// <reference types="react-dom/experimental" />
...
...
@@ -304,7 +305,15 @@ function devQueueSsrError(): Error | undefined {
'data-next-error-message'
)
!
const
stack
=
ssrErrorTemplateTag
.
getAttribute
(
'data-next-error-stack'
)
const
digest
=
ssrErrorTemplateTag
.
getAttribute
(
'data-next-error-digest'
)
const
error
=
new
Error
(
message
)
if
(
digest
)
{
;(
error
as
any
).
digest
=
digest
}
// Skip Next.js SSR'd internal errors that which will be handled by the error boundaries.
if
(
isNextRouterError
(
error
))
{
return
}
error
.
stack
=
stack
||
''
return
error
}
...
...
packages/next/src/server/app-render/app-render.tsx
View file @
ec1fefca
...
...
@@ -994,6 +994,7 @@ async function getErrorRSCPayload(
{
process
.
env
.
NODE_ENV
!==
'production'
&&
err
?
(
<
template
data
-
next
-
error
-
message=
{
err
.
message
}
data
-
next
-
error
-
digest=
{
'digest'
in
err
?
err
.
digest
:
''
}
data
-
next
-
error
-
stack=
{
err
.
stack
}
/>
)
:
null
}
...
...
test/development/app-dir/error-overlay/error-ignored-frames/error-ignored-frames.test.ts
View file @
ec1fefca
...
...
@@ -54,7 +54,7 @@ describe('error-ignored-frames', () => {
at OuterLayoutRouter (../src/client/components/layout-router.tsx (607:20))
at Router (../src/client/components/app-router.tsx (633:8))
at AppRouter (../src/client/components/app-router.tsx (679:8))
at ServerRoot (../src/client/app-index.tsx (20
0
:6))"
at ServerRoot (../src/client/app-index.tsx (20
1
:6))"
`
)
}
})
...
...
@@ -85,7 +85,7 @@ describe('error-ignored-frames', () => {
at ClientPageRoot (../src/client/components/client-page.tsx (60:13))
at Router (../src/client/components/app-router.tsx (633:8))
at AppRouter (../src/client/components/app-router.tsx (679:8))
at ServerRoot (../src/client/app-index.tsx (20
0
:6))"
at ServerRoot (../src/client/app-index.tsx (20
1
:6))"
`
)
}
})
...
...
@@ -128,7 +128,7 @@ describe('error-ignored-frames', () => {
at ClientPageRoot (../src/client/components/client-page.tsx (60:13))
at Router (../src/client/components/app-router.tsx (633:8))
at AppRouter (../src/client/components/app-router.tsx (679:8))
at ServerRoot (../src/client/app-index.tsx (20
0
:6))"
at ServerRoot (../src/client/app-index.tsx (20
1
:6))"
`
)
}
})
...
...
test/development/app-dir/ssr-only-error/app/notfound/page.tsx
0 → 100644
View file @
ec1fefca
import
{
notFound
}
from
'next/navigation'
export
default
async
function
Home
()
{
notFound
()
}
export
const
dynamic
=
'force-dynamic'
test/development/app-dir/ssr-only-error/ssr-only-error.test.ts
View file @
ec1fefca
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
assertNoRedbox
,
getRedboxDescription
,
getRedboxSource
,
hasErrorToast
,
...
...
@@ -40,4 +41,30 @@ describe('ssr-only-error', () => {
}
`
)
})
it
(
'should not handle internal nextjs errors that will be handled by error boundaries'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/notfound'
,
{
pushErrorAsConsoleLog
:
true
,
})
await
assertNoRedbox
(
browser
)
expect
(
await
hasErrorToast
(
browser
)).
toBe
(
false
)
const
text
=
await
browser
.
elementByCss
(
'body'
).
text
()
expect
(
text
).
toBe
(
'404
\
nThis page could not be found.'
)
// Assert there's only one console.error from browser itself
const
errorLogs
=
(
await
browser
.
log
()).
filter
(
(
log
)
=>
log
.
source
===
'error'
)
expect
(
errorLogs
).
toEqual
([
expect
.
objectContaining
({
source
:
'error'
,
message
:
expect
.
stringContaining
(
'the server responded with a status of 404'
),
}),
])
})
})
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