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
69333f51
Unverified
Commit
69333f51
authored
Feb 21, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Feb 21, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev-overlay] Isolate overlay from user space Components (#76277)
parent
22c8bd1a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
27 deletions
+23
-27
app-dev-overlay-error-boundary.tsx
.../react-dev-overlay/app/app-dev-overlay-error-boundary.tsx
+2
-8
app-dev-overlay.tsx
...ient/components/react-dev-overlay/app/app-dev-overlay.tsx
+9
-11
error-overlay.tsx
...rlay/ui/components/errors/error-overlay/error-overlay.tsx
+7
-2
hydration-error.test.ts
test/development/acceptance-app/hydration-error.test.ts
+4
-4
server-source-maps.test.ts
...e2e/app-dir/server-source-maps/server-source-maps.test.ts
+1
-2
No files found.
packages/next/src/client/components/react-dev-overlay/app/app-dev-overlay-error-boundary.tsx
View file @
69333f51
...
...
@@ -5,7 +5,6 @@ import { RuntimeErrorHandler } from '../../errors/runtime-error-handler'
type
AppDevOverlayErrorBoundaryProps
=
{
children
:
React
.
ReactNode
devOverlay
:
React
.
ReactNode
globalError
:
[
GlobalErrorComponent
,
React
.
ReactNode
]
onError
:
(
value
:
boolean
)
=>
void
}
...
...
@@ -62,18 +61,13 @@ export class AppDevOverlayErrorBoundary extends PureComponent<
}
render
()
{
const
{
children
,
globalError
,
devOverlay
}
=
this
.
props
const
{
children
,
globalError
}
=
this
.
props
const
{
isReactError
,
reactError
}
=
this
.
state
const
fallback
=
(
<
ErroredHtml
globalError=
{
globalError
}
error=
{
reactError
}
/>
)
return
(
<>
{
isReactError
?
fallback
:
children
}
{
devOverlay
}
</>
)
return
isReactError
?
fallback
:
children
}
}
packages/next/src/client/components/react-dev-overlay/app/app-dev-overlay.tsx
View file @
69333f51
...
...
@@ -16,8 +16,16 @@ export function AppDevOverlay({
children
:
React
.
ReactNode
})
{
const
[
isErrorOverlayOpen
,
setIsErrorOverlayOpen
]
=
useState
(
false
)
const
devOverlay
=
(
return
(
<>
<
AppDevOverlayErrorBoundary
globalError=
{
globalError
}
onError=
{
setIsErrorOverlayOpen
}
>
{
children
}
</
AppDevOverlayErrorBoundary
>
{
/* Fonts can only be loaded outside the Shadow DOM. */
}
<
FontStyles
/>
<
DevOverlay
...
...
@@ -27,14 +35,4 @@ export function AppDevOverlay({
/>
</>
)
return
(
<
AppDevOverlayErrorBoundary
devOverlay=
{
devOverlay
}
globalError=
{
globalError
}
onError=
{
setIsErrorOverlayOpen
}
>
{
children
}
</
AppDevOverlayErrorBoundary
>
)
}
packages/next/src/client/components/react-dev-overlay/ui/components/errors/error-overlay/error-overlay.tsx
View file @
69333f51
import
type
{
OverlayState
}
from
'../../../../shared'
import
{
Suspense
}
from
'react'
import
{
BuildError
}
from
'../../../container/build-error'
import
{
Errors
}
from
'../../../container/errors'
import
{
RootLayoutMissingTagsError
}
from
'../../../container/root-layout-missing-tags-error'
...
...
@@ -64,11 +65,15 @@ export function ErrorOverlay({
// No Runtime Errors.
if
(
!
runtimeErrors
.
length
)
{
return
null
// Workaround React quirk that triggers "Switch to client-side rendering" if
// we return no Suspense boundary here.
return
<
Suspense
/>
}
if
(
!
mounted
)
{
return
null
// Workaround React quirk that triggers "Switch to client-side rendering" if
// we return no Suspense boundary here.
return
<
Suspense
/>
}
return
(
...
...
test/development/acceptance-app/hydration-error.test.ts
View file @
69333f51
...
...
@@ -216,7 +216,7 @@ describe('Error overlay for hydration errors in App router', () => {
"...
<HotReload assetPrefix="" globalError={[...]}>
<AppDevOverlay state={{nextId:1, ...}} globalError={[...]}>
<AppDevOverlayErrorBoundary
devOverlay={<Fragment>}
globalError={[...]} onError={function bound dispatchSetState}>
<AppDevOverlayErrorBoundary globalError={[...]} onError={function bound dispatchSetState}>
<DevRootHTTPAccessFallbackBoundary>
<HTTPAccessFallbackBoundary notFound={<NotAllowedRootHTTPFallbackError>}>
<HTTPAccessFallbackErrorBoundary pathname="/" notFound={<NotAllowedRootHTTPFallbackError>} ...>
...
...
@@ -232,14 +232,14 @@ describe('Error overlay for hydration errors in App router', () => {
- className="server-html"
>
...
..."
..."
`
)
}
else
{
expect
(
pseudoHtml
).
toMatchInlineSnapshot
(
`
"...
<HotReload assetPrefix="" globalError={[...]}>
<AppDevOverlay state={{nextId:1, ...}} globalError={[...]}>
<AppDevOverlayErrorBoundary
devOverlay={<Fragment>}
globalError={[...]} onError={function bound dispatchSetState}>
<AppDevOverlayErrorBoundary globalError={[...]} onError={function bound dispatchSetState}>
<DevRootHTTPAccessFallbackBoundary>
<HTTPAccessFallbackBoundary notFound={<NotAllowedRootHTTPFallbackError>}>
<HTTPAccessFallbackErrorBoundary pathname="/" notFound={<NotAllowedRootHTTPFallbackError>} ...>
...
...
@@ -252,7 +252,7 @@ describe('Error overlay for hydration errors in App router', () => {
- className="server-html"
>
...
..."
..."
`
)
}
...
...
test/e2e/app-dir/server-source-maps/server-source-maps.test.ts
View file @
69333f51
...
...
@@ -216,10 +216,9 @@ describe('app-dir - server source maps', () => {
)
expect
(
cliOutput
).
toMatch
(
/digest: '
\d
+'/
)
// TODO(veil): Should be a single error
await
expect
(
browser
).
toDisplayRedbox
(
`
{
"count":
2
,
"count":
1
,
"description": "Error: Boom",
"environmentLabel": null,
"label": "Unhandled Runtime Error",
...
...
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