import React, { useMemo, useRef, Suspense, useCallback } from 'react'
import type { DebugInfo } from '../../shared/types'
import { Overlay, OverlayBackdrop } from '../components/overlay'
import { RuntimeError } from './runtime-error'
import { getErrorSource } from '../../../shared/lib/error-source'
import { HotlinkedText } from '../components/hot-linked-text'
import { PseudoHtmlDiff } from './runtime-error/component-stack-pseudo-html'
import {
ErrorOverlayLayout,
type ErrorOverlayLayoutProps,
} from '../components/errors/error-overlay-layout/error-overlay-layout'
import {
getHydrationErrorStackInfo,
isHydrationError,
NEXTJS_HYDRATION_ERROR_LINK,
} from '../../shared/react-19-hydration-error'
import type { ReadyRuntimeError } from '../utils/get-error-by-type'
import { useFrames } from '../utils/get-error-by-type'
import type { ErrorBaseProps } from '../components/errors/error-overlay/error-overlay'
import type { HydrationErrorState } from '../../shared/hydration-error'
import { useActiveRuntimeError } from '../hooks/use-active-runtime-error'
import { formatCodeFrame } from '../components/code-frame/parse-code-frame'
import stripAnsi from 'next/dist/compiled/strip-ansi'
interface ErrorsProps extends ErrorBaseProps {
getSquashedHydrationErrorDetails: (error: Error) => HydrationErrorState | null
runtimeErrors: ReadyRuntimeError[]
debugInfo: DebugInfo
onClose: () => void
}
function matchLinkType(text: string): string | null {
if (text.startsWith('https://nextjs.org')) {
return 'nextjs-link'
}
if (text.startsWith('https://') || text.startsWith('http://')) {
return 'external-link'
}
return null
}
function HydrationErrorDescription({ message }: { message: string }) {
return
generateMetadata() in an otherwise prerenderable page
When Document metadata is the only part of a page that cannot be
prerendered Next.js expects you to either make it prerenderable or
make some other part of the page non-prerenderable to avoid
unintentional partially dynamic pages. Uncached data such as{' '}
fetch(...), cached data with a low expire time, or{' '}
connection() are all examples of data that only resolve
on navigation.
Move the asynchronous await into a Cache Component (
"use cache")
. This allows Next.js to statically prerender{' '}
generateMetadata() as part of the HTML document, so it's
instantly visible to the user.
add connection() inside a {'
{' '}
somewhere in a Page or Layout. This tells Next.js that the page is
intended to have some non-prerenderable parts.
Learn more:{' '} https://nextjs.org/docs/messages/next-prerender-dynamic-metadata
generateMetadata() or
file-based metadata
When Document metadata is the only part of a page that cannot be prerendered Next.js expects you to either make it prerenderable or make some other part of the page non-prerenderable to avoid unintentional partially dynamic pages.
Remove the Runtime data access from generateMetadata()
. This allows Next.js to statically prerender{' '}
generateMetadata() as part of the HTML document, so it's
instantly visible to the user.
add connection() inside a {'
{' '}
somewhere in a Page or Layout. This tells Next.js that the page is
intended to have some non-prerenderable parts.
Note that if you are using file-based metadata, such as icons, inside a route with dynamic params then the only recourse is to make some other part of the page non-prerenderable.
Learn more:{' '} https://nextjs.org/docs/messages/next-prerender-dynamic-metadata
generateViewport()
Viewport metadata needs to be available on page load so accessing
data that waits for a user navigation while producing it prevents
Next.js from prerendering an initial UI. Uncached data such as{' '}
fetch(...), cached data with a low expire time, or{' '}
connection() are all examples of data that only resolve
on navigation.
Move the asynchronous await into a Cache Component (
"use cache")
. This allows Next.js to statically prerender{' '}
generateViewport() as part of the HTML document, so
it's instantly visible to the user.
Put a {' around your document{' '}
{''}.
This indicate to Next.js that you are opting into allowing blocking
navigations for any page.
Learn more:{' '} https://nextjs.org/docs/messages/next-prerender-dynamic-viewport
generateViewport()
Viewport metadata needs to be available on page load so accessing
data that comes from a user Request while producing it prevents
Next.js from prerendering an initial UI.
cookies(), headers(), and{' '}
searchParams, are examples of Runtime data that can
only come from a user request.
Remove the Runtime data requirement from{' '}
generateViewport. This allows Next.js to statically
prerender generateViewport() as part of the HTML
document, so it's instantly visible to the user.
Put a {' around your document{' '}
{''}.
This indicate to Next.js that you are opting into allowing blocking
navigations for any page.
params are usually considered Runtime data but if all
params are provided a value using generateStaticParams{' '}
they can be statically prerendered.
Learn more:{' '} https://nextjs.org/docs/messages/next-prerender-dynamic-viewport
generateMetadata() in an otherwise prerenderable page
When Document metadata is the only part of a page that cannot be
prerendered Next.js expects you to either make it prerenderable or
make some other part of the page non-prerenderable to avoid
unintentional partially dynamic pages. Uncached data such as{' '}
fetch(...), cached data with a low expire time, or{' '}
connection() are all examples of data that only resolve
on navigation.
Move the asynchronous await into a Cache Component (
"use cache")
. This allows Next.js to statically prerender{' '}
generateMetadata() as part of the HTML document, so
it's instantly visible to the user.
add connection() inside a {'
{' '}
somewhere in a Page or Layout. This tells Next.js that the page is
intended to have some non-prerenderable parts.
Learn more:{' '} https://nextjs.org/docs/messages/next-prerender-dynamic-metadata
generateMetadata() or
file-based metadata
When Document metadata is the only part of a page that cannot be prerendered Next.js expects you to either make it prerenderable or make some other part of the page non-prerenderable to avoid unintentional partially dynamic pages.
Remove the Runtime data access from{' '}
generateMetadata()
. This allows Next.js to statically prerender{' '}
generateMetadata() as part of the HTML document, so
it's instantly visible to the user.
add connection() inside a {'
{' '}
somewhere in a Page or Layout. This tells Next.js that the page is
intended to have some non-prerenderable parts.
Note that if you are using file-based metadata, such as icons, inside a route with dynamic params then the only recourse is to make some other part of the page non-prerenderable.
Learn more:{' '} https://nextjs.org/docs/messages/next-prerender-dynamic-metadata
This delays the entire page from rendering, resulting in a slow user
experience. Next.js uses this error to ensure your app loads instantly
on every navigation. cookies(), headers(),
and searchParams, are examples of Runtime data that can
only come from a user request.
Provide a fallback UI using {'
Move the Runtime data access into a deeper component wrapped in{' '}
{'
In either case this allows Next.js to stream its contents to the user when they request the page, while still providing an initial UI that is prerendered and prefetchable for instant navigations.
Learn more:{' '} https://nextjs.org/docs/messages/blocking-route
This delays the entire page from rendering, resulting in a slow user
experience. Next.js uses this error to ensure your app loads instantly
on every navigation. Uncached data such as fetch(...),
cached data with a low expire time, or connection() are
all examples of data that only resolve on navigation.
Provide a fallback UI using {'
Move the asynchronous await into a Cache Component (
"use cache")
. This allows Next.js to statically prerender the component as part of
the HTML document, so it's instantly visible to the user.
Learn more:{' '} https://nextjs.org/docs/messages/blocking-route
{errorDetails.notes}
> ) : null} {errorDetails.warning ? (