Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ function ReplaySsrOnlyErrors({
return null
}

function getSquashedHydrationErrorDetails() {
// We don't squash hydration errors in the App Router.
return null
}

export function AppDevOverlay({
state,
dispatch,
Expand Down Expand Up @@ -99,7 +104,11 @@ export function AppDevOverlay({
<>
{/* Fonts can only be loaded outside the Shadow DOM. */}
<FontStyles />
<DevOverlay state={state} dispatch={dispatch} />
<DevOverlay
state={state}
dispatch={dispatch}
getSquashedHydrationErrorDetails={getSquashedHydrationErrorDetails}
/>
</>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
isErrorMessageWithComponentStackDiff as isReact19HydrationWarning,
} from '../../react-19-hydration-error'

type HydrationErrorState = {
export type HydrationErrorState = {
// Hydration warning template format: <message> <serverContent> <clientContent>
warning?: string
reactOutputComponentDiff?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PagesDevOverlayErrorBoundary } from './pages-dev-overlay-error-boundary
import { usePagesDevOverlay } from './hooks'
import { FontStyles } from '../font/font-styles'
import { DevOverlay } from '../ui/dev-overlay'
import { getSquashedHydrationErrorDetails } from './hydration-error-state'

export type ErrorType = 'runtime' | 'build'

Expand All @@ -22,7 +23,11 @@ export function PagesDevOverlay({ children }: PagesDevOverlayProps) {

{/* Fonts can only be loaded outside the Shadow DOM. */}
<FontStyles />
<DevOverlay state={state} dispatch={dispatch} />
<DevOverlay
state={state}
dispatch={dispatch}
getSquashedHydrationErrorDetails={getSquashedHydrationErrorDetails}
/>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { BuildError } from '../../../container/build-error'
import { Errors } from '../../../container/errors'
import { useDelayedRender } from '../../../hooks/use-delayed-render'
import type { ReadyRuntimeError } from '../../../../utils/get-error-by-type'
import type { HydrationErrorState } from '../../../../pages/hydration-error-state'

const transitionDurationMs = 200

Expand All @@ -23,11 +24,13 @@ export interface ErrorBaseProps {
export function ErrorOverlay({
state,
dispatch,
getSquashedHydrationErrorDetails,
runtimeErrors,
errorCount,
}: {
state: OverlayState
dispatch: OverlayDispatch
getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null
runtimeErrors: ReadyRuntimeError[]
errorCount: number
}) {
Expand Down Expand Up @@ -74,6 +77,7 @@ export function ErrorOverlay({
<Errors
{...commonProps}
debugInfo={state.debugInfo}
getSquashedHydrationErrorDetails={getSquashedHydrationErrorDetails}
runtimeErrors={runtimeErrors}
onClose={() => {
dispatch({ type: ACTION_ERROR_OVERLAY_CLOSE })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import {
} from '../../../react-19-hydration-error'
import type { ReadyRuntimeError } from '../../utils/get-error-by-type'
import type { ErrorBaseProps } from '../components/errors/error-overlay/error-overlay'
import { getSquashedHydrationErrorDetails } from '../../pages/hydration-error-state'
import type { HydrationErrorState } from '../../pages/hydration-error-state'

export interface ErrorsProps extends ErrorBaseProps {
getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null
runtimeErrors: ReadyRuntimeError[]
debugInfo: DebugInfo
onClose: () => void
Expand Down Expand Up @@ -72,7 +73,10 @@ const noErrorDetails = {
notes: null,
reactOutputComponentDiff: null,
}
function useErrorDetails(error: Error | undefined): {
function useErrorDetails(
error: Error | undefined,
getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null
): {
hydrationWarning: string | null
notes: string | null
reactOutputComponentDiff: string | null
Expand Down Expand Up @@ -106,10 +110,11 @@ function useErrorDetails(error: Error | undefined): {
notes,
reactOutputComponentDiff: diff,
}
}, [error])
}, [error, getSquashedHydrationErrorDetails])
}

export function Errors({
getSquashedHydrationErrorDetails,
runtimeErrors,
debugInfo,
onClose,
Expand All @@ -127,7 +132,10 @@ export function Errors({
() => runtimeErrors[activeIdx] ?? null,
[activeIdx, runtimeErrors]
)
const errorDetails = useErrorDetails(activeError?.error)
const errorDetails = useErrorDetails(
activeError?.error,
getSquashedHydrationErrorDetails
)

if (isLoading) {
// TODO: better loading state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ function useOverlayReducer() {
}, initialState)
}

function getNoSquashedHydrationErrorDetails() {
return null
}

export const Default: Story = {
render: function DevOverlayStory() {
const [state, dispatch] = useOverlayReducer()
Expand All @@ -115,7 +119,14 @@ export const Default: Story = {
objectFit: 'contain',
}}
/>
<DevOverlay state={state} dispatch={dispatch} />
<DevOverlay
state={state}
dispatch={dispatch}
getSquashedHydrationErrorDetails={
// Testing like App Router where we no longer quash hydration errors
getNoSquashedHydrationErrorDetails
}
/>
</>
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import { DevToolsIndicator } from './components/errors/dev-tools-indicator/dev-t
import { RenderError } from './container/runtime-error/render-error'
import { DarkTheme } from './styles/dark-theme'
import { useDevToolsScale } from './components/errors/dev-tools-indicator/dev-tools-info/preferences'
import type { HydrationErrorState } from '../pages/hydration-error-state'

export function DevOverlay({
state,
dispatch,
getSquashedHydrationErrorDetails,
}: {
state: OverlayState
dispatch: OverlayDispatch
getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null
}) {
const [scale, setScale] = useDevToolsScale()
return (
Expand Down Expand Up @@ -46,6 +49,9 @@ export function DevOverlay({
<ErrorOverlay
state={state}
dispatch={dispatch}
getSquashedHydrationErrorDetails={
getSquashedHydrationErrorDetails
}
runtimeErrors={runtimeErrors}
errorCount={totalErrorCount}
/>
Expand Down
Loading