Unverified Commit 4e3eb513 authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

Polish instant fix cards and validation messages (#93894)

### What?

- Rename cards to plain English: `Prerender params if known`, `Mark the
route as dynamic`, `For telemetry, use a timing API`.
- Remove `Wrap body in Suspense` card from viewport variants.
- Body errors: `during the initial render` → `during prerendering`;
`blocking navigation` → `blocking the page load`.
- Server sync IO leads with `the unstable value <expression>`.
- Client sync IO drops `fixed at build time`.
- New loading-state icon for the `block` group.

### Demo

- [Fix
Overview](https://error-messages-overhaul-ibsl.labs.vercel.dev/fix-overview)

<!-- NEXT_JS_LLM_PR -->

---------
Co-authored-by: 's avatarCursor <cursoragent@cursor.com>
parent d13adce3
This diff is collapsed.
...@@ -39,6 +39,7 @@ export const DIALOG_STYLES = ` ...@@ -39,6 +39,7 @@ export const DIALOG_STYLES = `
.error-overlay-dialog-scroll { .error-overlay-dialog-scroll {
overflow-y: auto; overflow-y: auto;
scrollbar-gutter: stable;
height: 100%; height: 100%;
} }
` `
...@@ -16,7 +16,7 @@ export type FixCardIcon = ...@@ -16,7 +16,7 @@ export type FixCardIcon =
| 'database' | 'database'
| 'history' | 'history'
| 'layout' | 'layout'
| 'octagon' | 'loading'
| 'pointer-click' | 'pointer-click'
| 'server-stack' | 'server-stack'
| 'timer' | 'timer'
...@@ -28,7 +28,7 @@ export const FIX_CARD_GROUPS: Record< ...@@ -28,7 +28,7 @@ export const FIX_CARD_GROUPS: Record<
> = { > = {
stream: { label: 'Stream', color: 'blue', icon: 'align-left' }, stream: { label: 'Stream', color: 'blue', icon: 'align-left' },
prerender: { label: 'Prerender', color: 'purple', icon: 'history' }, prerender: { label: 'Prerender', color: 'purple', icon: 'history' },
block: { label: 'Block', color: 'red', icon: 'octagon' }, block: { label: 'Block', color: 'red', icon: 'loading' },
cache: { label: 'Cache', color: 'purple', icon: 'database' }, cache: { label: 'Cache', color: 'purple', icon: 'database' },
static: { label: 'Static', color: 'gray', icon: 'zap' }, static: { label: 'Static', color: 'gray', icon: 'zap' },
dynamic: { label: 'Dynamic', color: 'blue', icon: 'server-stack' }, dynamic: { label: 'Dynamic', color: 'blue', icon: 'server-stack' },
...@@ -77,7 +77,7 @@ const runtimeCards: FixCard[] = [ ...@@ -77,7 +77,7 @@ const runtimeCards: FixCard[] = [
}, },
{ {
id: 'prerender-known-params', id: 'prerender-known-params',
title: 'Prerender known params', title: 'For known params, prerender',
group: 'cache', group: 'cache',
link: 'https://nextjs.org/docs/messages/blocking-route#prerender-known-params', link: 'https://nextjs.org/docs/messages/blocking-route#prerender-known-params',
snippets: [ snippets: [
...@@ -162,7 +162,7 @@ const metadataRuntimeCards: FixCard[] = [ ...@@ -162,7 +162,7 @@ const metadataRuntimeCards: FixCard[] = [
}, },
{ {
id: 'render-page-at-request-time', id: 'render-page-at-request-time',
title: 'Generate the page on every request', title: 'Mark the route as dynamic',
group: 'dynamic', group: 'dynamic',
link: 'https://nextjs.org/docs/messages/next-prerender-dynamic-metadata#render-page-at-request-time', link: 'https://nextjs.org/docs/messages/next-prerender-dynamic-metadata#render-page-at-request-time',
snippets: [ snippets: [
...@@ -186,7 +186,7 @@ const metadataDynamicCards: FixCard[] = [ ...@@ -186,7 +186,7 @@ const metadataDynamicCards: FixCard[] = [
}, },
{ {
id: 'render-page-at-request-time', id: 'render-page-at-request-time',
title: 'Generate the page on every request', title: 'Mark the route as dynamic',
group: 'dynamic', group: 'dynamic',
link: 'https://nextjs.org/docs/messages/next-prerender-dynamic-metadata#render-page-at-request-time', link: 'https://nextjs.org/docs/messages/next-prerender-dynamic-metadata#render-page-at-request-time',
snippets: [ snippets: [
...@@ -210,17 +210,6 @@ const viewportRuntimeCards: FixCard[] = [ ...@@ -210,17 +210,6 @@ const viewportRuntimeCards: FixCard[] = [
{ text: '}' }, { text: '}' },
], ],
}, },
{
id: 'wrap-body-in-suspense',
title: 'Wrap body in Suspense',
group: 'stream',
link: 'https://nextjs.org/docs/messages/next-prerender-dynamic-viewport#wrap-body-in-suspense',
snippets: [
{ text: '<Suspense>', highlight: true },
{ text: ' <body>{children}</body>' },
{ text: '</Suspense>', highlight: true },
],
},
{ {
id: 'allow-blocking-route', id: 'allow-blocking-route',
title: 'Allow blocking route', title: 'Allow blocking route',
...@@ -245,17 +234,6 @@ const viewportDynamicCards: FixCard[] = [ ...@@ -245,17 +234,6 @@ const viewportDynamicCards: FixCard[] = [
{ text: ' return await db.getViewport(…)' }, { text: ' return await db.getViewport(…)' },
], ],
}, },
{
id: 'wrap-body-in-suspense',
title: 'Wrap body in Suspense',
group: 'stream',
link: 'https://nextjs.org/docs/messages/next-prerender-dynamic-viewport#wrap-body-in-suspense',
snippets: [
{ text: '<Suspense>', highlight: true },
{ text: ' <body>{children}</body>' },
{ text: '</Suspense>', highlight: true },
],
},
{ {
id: 'allow-blocking-route', id: 'allow-blocking-route',
title: 'Allow blocking route', title: 'Allow blocking route',
...@@ -300,8 +278,8 @@ const syncMathCards: FixCard[] = [ ...@@ -300,8 +278,8 @@ const syncMathCards: FixCard[] = [
link: 'https://nextjs.org/docs/messages/next-prerender-random#render-on-the-client', link: 'https://nextjs.org/docs/messages/next-prerender-random#render-on-the-client',
snippets: [ snippets: [
{ text: '"use client"', highlight: true }, { text: '"use client"', highlight: true },
{ text: 'const [id] = useState(() => Math.random())' }, { text: '// runs in the browser' },
{ text: 'return <Item id={id} />' }, { text: 'const id = Math.random()' },
], ],
}, },
] ]
...@@ -336,13 +314,13 @@ const syncDateCards: FixCard[] = [ ...@@ -336,13 +314,13 @@ const syncDateCards: FixCard[] = [
link: 'https://nextjs.org/docs/messages/next-prerender-current-time#render-on-the-client', link: 'https://nextjs.org/docs/messages/next-prerender-current-time#render-on-the-client',
snippets: [ snippets: [
{ text: '"use client"', highlight: true }, { text: '"use client"', highlight: true },
{ text: 'useEffect(() => setT(Date.now()), [])' }, { text: '// runs in the browser' },
{ text: 'return <Banner time={t} />' }, { text: 'const t = Date.now()' },
], ],
}, },
{ {
id: 'measure-elapsed-time', id: 'measure-elapsed-time',
title: 'Measure elapsed time', title: 'For telemetry, use a timing API',
group: 'measure', group: 'measure',
link: 'https://nextjs.org/docs/messages/next-prerender-current-time#measure-elapsed-time', link: 'https://nextjs.org/docs/messages/next-prerender-current-time#measure-elapsed-time',
snippets: [ snippets: [
...@@ -383,8 +361,8 @@ const syncCryptoCards: FixCard[] = [ ...@@ -383,8 +361,8 @@ const syncCryptoCards: FixCard[] = [
link: 'https://nextjs.org/docs/messages/next-prerender-crypto#render-on-the-client', link: 'https://nextjs.org/docs/messages/next-prerender-crypto#render-on-the-client',
snippets: [ snippets: [
{ text: '"use client"', highlight: true }, { text: '"use client"', highlight: true },
{ text: 'const [id] = useState(() => crypto.randomUUID())' }, { text: '// runs in the browser' },
{ text: 'return <Token id={id} />' }, { text: 'const id = crypto.randomUUID()' },
], ],
}, },
] ]
...@@ -416,7 +394,7 @@ const syncClientDateCards: FixCard[] = [ ...@@ -416,7 +394,7 @@ const syncClientDateCards: FixCard[] = [
}, },
{ {
id: 'measure-elapsed-time', id: 'measure-elapsed-time',
title: 'Measure elapsed time', title: 'For telemetry, use a timing API',
group: 'measure', group: 'measure',
link: 'https://nextjs.org/docs/messages/next-prerender-current-time-client#measure-elapsed-time', link: 'https://nextjs.org/docs/messages/next-prerender-current-time-client#measure-elapsed-time',
snippets: [ snippets: [
......
...@@ -3,7 +3,7 @@ import { ...@@ -3,7 +3,7 @@ import {
FixCardDatabaseIcon, FixCardDatabaseIcon,
FixCardHistoryIcon, FixCardHistoryIcon,
FixCardLayoutIcon, FixCardLayoutIcon,
FixCardOctagonIcon, FixCardLoadingIcon,
FixCardPointerClickIcon, FixCardPointerClickIcon,
FixCardServerStackIcon, FixCardServerStackIcon,
FixCardTimerIcon, FixCardTimerIcon,
...@@ -41,8 +41,8 @@ function getCardIcon(icon: FixCardIcon) { ...@@ -41,8 +41,8 @@ function getCardIcon(icon: FixCardIcon) {
return <FixCardDatabaseIcon /> return <FixCardDatabaseIcon />
case 'timer': case 'timer':
return <FixCardTimerIcon /> return <FixCardTimerIcon />
case 'octagon': case 'loading':
return <FixCardOctagonIcon /> return <FixCardLoadingIcon />
case 'zap': case 'zap':
return <FixCardZapIcon /> return <FixCardZapIcon />
case 'layout': case 'layout':
...@@ -237,7 +237,6 @@ export const INSTANT_GUIDANCE_STYLES = css` ...@@ -237,7 +237,6 @@ export const INSTANT_GUIDANCE_STYLES = css`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-width: 0; min-width: 0;
overflow: hidden;
position: relative; position: relative;
text-decoration: none; text-decoration: none;
} }
...@@ -254,6 +253,15 @@ export const INSTANT_GUIDANCE_STYLES = css` ...@@ -254,6 +253,15 @@ export const INSTANT_GUIDANCE_STYLES = css`
background: var(--color-background-200); background: var(--color-background-200);
} }
[data-nextjs-fix-card]:hover [data-nextjs-fix-card-link-icon] {
color: var(--color-gray-1000);
}
[data-nextjs-fix-card]:hover [data-nextjs-fix-snippet] {
border-color: var(--color-gray-500);
background: var(--color-gray-100);
}
a[data-nextjs-fix-card]:focus-visible { a[data-nextjs-fix-card]:focus-visible {
outline: var(--focus-ring); outline: var(--focus-ring);
outline-offset: 2px; outline-offset: 2px;
...@@ -333,6 +341,7 @@ export const INSTANT_GUIDANCE_STYLES = css` ...@@ -333,6 +341,7 @@ export const INSTANT_GUIDANCE_STYLES = css`
line-height: 1.5; line-height: 1.5;
margin: 0; margin: 0;
margin-left: -1px; margin-left: -1px;
margin-bottom: -1px;
padding: 14px 16px; padding: 14px 16px;
width: calc(100% + 2px); width: calc(100% + 2px);
white-space: pre; white-space: pre;
...@@ -346,11 +355,6 @@ export const INSTANT_GUIDANCE_STYLES = css` ...@@ -346,11 +355,6 @@ export const INSTANT_GUIDANCE_STYLES = css`
text-align: left; text-align: left;
} }
[data-nextjs-fix-card]:hover [data-nextjs-fix-snippet] {
border-color: var(--color-gray-500);
background: var(--color-gray-100);
}
[data-snippet-line] { [data-snippet-line] {
display: block; display: block;
color: var(--color-gray-800); color: var(--color-gray-800);
......
...@@ -325,7 +325,7 @@ export function isSyncIOClientError(message: string): boolean { ...@@ -325,7 +325,7 @@ export function isSyncIOClientError(message: string): boolean {
// Detects errors emitted during navigation-phase instant validation: body // Detects errors emitted during navigation-phase instant validation: body
// errors from `createRuntimeBodyErrorInNavigation` / // errors from `createRuntimeBodyErrorInNavigation` /
// `createDynamicBodyErrorInNavigation` (SSR factories instead say "during // `createDynamicBodyErrorInNavigation` (SSR factories instead say "during
// the initial render"), and validation errors from // prerendering"), and validation errors from
// `trackDynamicHoleInNavigation` / `getNavigationDisallowedDynamicReasons`. // `trackDynamicHoleInNavigation` / `getNavigationDisallowedDynamicReasons`.
export function isBlockingRouteInNavError(message: string): boolean { export function isBlockingRouteInNavError(message: string): boolean {
return ( return (
...@@ -559,10 +559,10 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\ ...@@ -559,10 +559,10 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\
errorDetails.variant === 'runtime' errorDetails.variant === 'runtime'
? errorDetails.inNavigation ? errorDetails.inNavigation
? 'Next.js encountered runtime data during a navigation.' ? 'Next.js encountered runtime data during a navigation.'
: 'Next.js encountered runtime data during the initial render.' : 'Next.js encountered runtime data during prerendering.'
: errorDetails.inNavigation : errorDetails.inNavigation
? 'Next.js encountered uncached data during a navigation.' ? 'Next.js encountered uncached data during a navigation.'
: 'Next.js encountered uncached data during the initial render.' : 'Next.js encountered uncached data during prerendering.'
} }
headerChildren={ headerChildren={
<InstantHeaderExplanation <InstantHeaderExplanation
...@@ -684,8 +684,8 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\ ...@@ -684,8 +684,8 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\
errorType={errorType} errorType={errorType}
errorMessage={ errorMessage={
<> <>
Next.js encountered <code>{errorDetails.cause}</code> without an Next.js encountered the unstable value{' '}
explicit rendering intent. <code>{errorDetails.cause}</code> while prerendering.
</> </>
} }
headerChildren={ headerChildren={
...@@ -724,13 +724,13 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\ ...@@ -724,13 +724,13 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\
errorType={errorType} errorType={errorType}
errorMessage={ errorMessage={
<> <>
Next.js encountered <code>{errorDetails.cause}</code> in a Client Next.js encountered the unstable value{' '}
Component. <code>{errorDetails.cause}</code> in a Client Component.
</> </>
} }
headerChildren={ headerChildren={
<InstantHeaderExplanation <InstantHeaderExplanation
explanation="This value would be evaluated during the prerender and fixed at build time, instead of recomputed on each visit." explanation="This value would be evaluated during the prerender, instead of recomputed on each visit."
docsUrl={SYNC_IO_CLIENT_DOCS[errorDetails.cause]} docsUrl={SYNC_IO_CLIENT_DOCS[errorDetails.cause]}
/> />
} }
......
...@@ -46,7 +46,7 @@ export function FixCardHistoryIcon() { ...@@ -46,7 +46,7 @@ export function FixCardHistoryIcon() {
) )
} }
export function FixCardOctagonIcon() { export function FixCardLoadingIcon() {
return ( return (
<svg <svg
width="16" width="16"
...@@ -55,12 +55,23 @@ export function FixCardOctagonIcon() { ...@@ -55,12 +55,23 @@ export function FixCardOctagonIcon() {
fill="none" fill="none"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path {Array.from({ length: 12 }, (_, index) => {
fill="currentColor" const angle = index * 30
fillRule="evenodd" const opacity = 1 - index * 0.05
clipRule="evenodd"
d="M14.5 8a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-5.5-2.5h-5v5h5z" return (
/> <circle
key={angle}
cx="8"
cy="2.3"
r="0.9"
fill="currentColor"
stroke="none"
opacity={opacity}
transform={`rotate(${angle} 8 8)`}
/>
)
})}
</svg> </svg>
) )
} }
......
export function createRuntimeBodyError(route: string): Error { export function createRuntimeBodyError(route: string): Error {
return new Error( return new Error(
`Route "${route}": Next.js encountered runtime data during the initial render.\n\n` + `Route "${route}": Next.js encountered runtime data during prerendering.\n\n` +
`\`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking navigation and leading to a slower user experience.\n\n` + `\`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.\n\n` +
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` + ` - Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` - Use \`generateStaticParams\` to make route params static\n` + ` - If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`\n` +
` - Set \`export const instant = false\` to allow a blocking route\n\n` + ` - Set \`export const instant = false\` to allow a blocking route\n\n` +
`Learn more: https://nextjs.org/docs/messages/blocking-route` `Learn more: https://nextjs.org/docs/messages/blocking-route`
) )
...@@ -12,8 +12,8 @@ export function createRuntimeBodyError(route: string): Error { ...@@ -12,8 +12,8 @@ export function createRuntimeBodyError(route: string): Error {
export function createDynamicBodyError(route: string): Error { export function createDynamicBodyError(route: string): Error {
return new Error( return new Error(
`Route "${route}": Next.js encountered uncached data during the initial render.\n\n` + `Route "${route}": Next.js encountered uncached data during prerendering.\n\n` +
`\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking navigation and leading to a slower user experience.\n\n` + `\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.\n\n` +
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Cache the data access with \`"use cache"\`\n` + ` - Cache the data access with \`"use cache"\`\n` +
` - Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` + ` - Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
...@@ -24,11 +24,11 @@ export function createDynamicBodyError(route: string): Error { ...@@ -24,11 +24,11 @@ export function createDynamicBodyError(route: string): Error {
export function createRuntimeBodyErrorInNavigation(route: string): Error { export function createRuntimeBodyErrorInNavigation(route: string): Error {
return new Error( return new Error(
`Route "${route}": Next.js encountered runtime data during the initial render or a navigation.\n\n` + `Route "${route}": Next.js encountered runtime data during prerendering or a navigation.\n\n` +
`\`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.\n\n` + `\`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.\n\n` +
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` + ` - Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` - Use \`generateStaticParams\` to make route params static\n` + ` - If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`\n` +
` - Set \`export const instant = false\` to allow a blocking route\n\n` + ` - Set \`export const instant = false\` to allow a blocking route\n\n` +
`Learn more: https://nextjs.org/docs/messages/blocking-route` `Learn more: https://nextjs.org/docs/messages/blocking-route`
) )
...@@ -36,7 +36,7 @@ export function createRuntimeBodyErrorInNavigation(route: string): Error { ...@@ -36,7 +36,7 @@ export function createRuntimeBodyErrorInNavigation(route: string): Error {
export function createDynamicBodyErrorInNavigation(route: string): Error { export function createDynamicBodyErrorInNavigation(route: string): Error {
return new Error( return new Error(
`Route "${route}": Next.js encountered uncached data during the initial render or a navigation.\n\n` + `Route "${route}": Next.js encountered uncached data during prerendering or a navigation.\n\n` +
`\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.\n\n` + `\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.\n\n` +
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Cache the data access with \`"use cache"\`\n` + ` - Cache the data access with \`"use cache"\`\n` +
...@@ -53,12 +53,12 @@ export function createDynamicBodyErrorInNavigation(route: string): Error { ...@@ -53,12 +53,12 @@ export function createDynamicBodyErrorInNavigation(route: string): Error {
*/ */
export function createDynamicOrRuntimeBodyError(route: string): Error { export function createDynamicOrRuntimeBodyError(route: string): Error {
return new Error( return new Error(
`Route "${route}": Next.js encountered uncached or runtime data during the initial render.\n\n` + `Route "${route}": Next.js encountered uncached or runtime data during prerendering.\n\n` +
`\`fetch(...)\`, \`cookies()\`, \`headers()\`, \`params\`, \`searchParams\`, or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking navigation and leading to a slower user experience.\n\n` + `\`fetch(...)\`, \`cookies()\`, \`headers()\`, \`params\`, \`searchParams\`, or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered, blocking the page load and leading to a slower user experience.\n\n` +
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Cache the data access with \`"use cache"\`\n` + ` - Cache the data access with \`"use cache"\`\n` +
` - Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` + ` - Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` - Use \`generateStaticParams\` to make route params static\n` + ` - If the runtime data is \`params\` and they're known, prerender them with \`generateStaticParams\`\n` +
` - Set \`export const instant = false\` to allow a blocking route\n\n` + ` - Set \`export const instant = false\` to allow a blocking route\n\n` +
`Learn more: https://nextjs.org/docs/messages/blocking-route` `Learn more: https://nextjs.org/docs/messages/blocking-route`
) )
...@@ -92,7 +92,6 @@ export function createRuntimeViewportError(route: string): Error { ...@@ -92,7 +92,6 @@ export function createRuntimeViewportError(route: string): Error {
`\`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` in \`generateViewport()\` prevents the page from being prerendered, leading to a slower user experience.\n\n` + `\`cookies()\`, \`headers()\`, \`params\`, or \`searchParams\` in \`generateViewport()\` prevents the page from being prerendered, leading to a slower user experience.\n\n` +
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Use a static viewport export instead of \`generateViewport()\`\n` + ` - Use a static viewport export instead of \`generateViewport()\`\n` +
` - Wrap your document \`<body>\` in \`<Suspense>\`\n` +
` - Set \`export const instant = false\` to allow a blocking route\n\n` + ` - Set \`export const instant = false\` to allow a blocking route\n\n` +
`Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport` `Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport`
) )
...@@ -104,7 +103,6 @@ export function createDynamicViewportError(route: string): Error { ...@@ -104,7 +103,6 @@ export function createDynamicViewportError(route: string): Error {
`\`fetch(...)\` or \`connection()\` in \`generateViewport()\` prevents the page from being prerendered, leading to a slower user experience.\n\n` + `\`fetch(...)\` or \`connection()\` in \`generateViewport()\` prevents the page from being prerendered, leading to a slower user experience.\n\n` +
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Cache the viewport data with \`"use cache"\` in \`generateViewport()\`\n` + ` - Cache the viewport data with \`"use cache"\` in \`generateViewport()\`\n` +
` - Wrap your document \`<body>\` in \`<Suspense>\`\n` +
` - Set \`export const instant = false\` to allow a blocking route\n\n` + ` - Set \`export const instant = false\` to allow a blocking route\n\n` +
`Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport` `Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport`
) )
...@@ -122,7 +120,6 @@ export function createDynamicOrRuntimeViewportError(route: string): Error { ...@@ -122,7 +120,6 @@ export function createDynamicOrRuntimeViewportError(route: string): Error {
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Use a static viewport export instead of \`generateViewport()\`\n` + ` - Use a static viewport export instead of \`generateViewport()\`\n` +
` - Cache the viewport data with \`"use cache"\` in \`generateViewport()\`\n` + ` - Cache the viewport data with \`"use cache"\` in \`generateViewport()\`\n` +
` - Wrap your document \`<body>\` in \`<Suspense>\`\n` +
` - Set \`export const instant = false\` to allow a blocking route\n\n` + ` - Set \`export const instant = false\` to allow a blocking route\n\n` +
`Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport` `Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport`
) )
......
...@@ -20,7 +20,7 @@ const SYNC_IO_RUNTIME_DOCS: Record<SyncIOApiType, string> = { ...@@ -20,7 +20,7 @@ const SYNC_IO_RUNTIME_DOCS: Record<SyncIOApiType, string> = {
function elapsedTimeBullet(type: SyncIOApiType): string { function elapsedTimeBullet(type: SyncIOApiType): string {
return type === 'time' return type === 'time'
? ` - Measure elapsed time with \`performance.now()\` instead of \`Date.now()\`\n` ? ` - If the value is for telemetry, use a timing API such as \`performance.now()\`\n`
: '' : ''
} }
...@@ -31,7 +31,7 @@ function createSyncIOErrorImpl( ...@@ -31,7 +31,7 @@ function createSyncIOErrorImpl(
docsUrl: string docsUrl: string
): Error { ): Error {
return new Error( return new Error(
`Route "${route}": Next.js encountered ${expression} without an explicit rendering intent.\n\n` + `Route "${route}": Next.js encountered the unstable value ${expression} while prerendering.\n\n` +
`This value can change between renders, so it must be either prerendered or computed later.\n\n` + `This value can change between renders, so it must be either prerendered or computed later.\n\n` +
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Render at request time by adding a dynamic data access (e.g. \`await connection()\`) before this call\n` + ` - Render at request time by adding a dynamic data access (e.g. \`await connection()\`) before this call\n` +
...@@ -70,11 +70,12 @@ export function createSyncIOClientError( ...@@ -70,11 +70,12 @@ export function createSyncIOClientError(
type: SyncIOApiType type: SyncIOApiType
): Error { ): Error {
return new Error( return new Error(
`Route "${route}": Next.js encountered ${expression} in a Client Component.\n\n` + `Route "${route}": Next.js encountered the unstable value ${expression} in a Client Component.\n\n` +
`This value would be evaluated during the prerender and fixed at build time, instead of recomputed on each visit.\n\n` + `This value would be evaluated during the prerender, instead of recomputed on each visit.\n\n` +
`Ways to fix this:\n` + `Ways to fix this:\n` +
` - Wrap the Client Component in \`<Suspense fallback={...}>\`\n` + ` - Wrap the Client Component in \`<Suspense fallback={...}>\`\n` +
` - Move the read into a \`useEffect\` or event handler\n` + ` - Move the read into a \`useEffect\` or event handler\n` +
elapsedTimeBullet(type) +
`\n` + `\n` +
`Learn more: ${SYNC_IO_CLIENT_DOCS[type]}` `Learn more: ${SYNC_IO_CLIENT_DOCS[type]}`
) )
......
...@@ -75,12 +75,12 @@ describe('Cache Components Dev Errors', () => { ...@@ -75,12 +75,12 @@ describe('Cache Components Dev Errors', () => {
await openRedbox(browser) await openRedbox(browser)
desc = await getRedboxDescription(browser) desc = await getRedboxDescription(browser)
expect(desc).toContain('during the initial render') expect(desc).toContain('during prerendering')
await browser.refresh() await browser.refresh()
await openRedbox(browser) await openRedbox(browser)
desc = await getRedboxDescription(browser) desc = await getRedboxDescription(browser)
expect(desc).toContain('during the initial render') expect(desc).toContain('during prerendering')
}) })
}) })
...@@ -21,8 +21,8 @@ describe('Cache Components Dev Errors', () => { ...@@ -21,8 +21,8 @@ describe('Cache Components Dev Errors', () => {
// soft-navigating to the page (see test below). // soft-navigating to the page (see test below).
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1242", "code": "E1261",
"description": "Next.js encountered Math.random() without an explicit rendering intent.", "description": "Next.js encountered the unstable value Math.random() while prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/error/page.tsx (2:23) @ Page "source": "app/error/page.tsx (2:23) @ Page
...@@ -51,8 +51,8 @@ describe('Cache Components Dev Errors', () => { ...@@ -51,8 +51,8 @@ describe('Cache Components Dev Errors', () => {
// TODO: React should not include the anon stack in the Owner Stack. // TODO: React should not include the anon stack in the Owner Stack.
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1242", "code": "E1261",
"description": "Next.js encountered Math.random() without an explicit rendering intent.", "description": "Next.js encountered the unstable value Math.random() while prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/error/page.tsx (2:23) @ Page "source": "app/error/page.tsx (2:23) @ Page
...@@ -98,8 +98,8 @@ describe('Cache Components Dev Errors', () => { ...@@ -98,8 +98,8 @@ describe('Cache Components Dev Errors', () => {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1220", "code": "E1265",
"description": "Next.js encountered uncached data during the initial render.", "description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/no-accessed-data/page.js (2:9) @ Page "source": "app/no-accessed-data/page.js (2:9) @ Page
......
...@@ -52,8 +52,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -52,8 +52,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page "source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
...@@ -67,8 +67,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -67,8 +67,8 @@ describe('Cache Components Fallback Validation', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page "source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
...@@ -85,8 +85,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -85,8 +85,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page "source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
...@@ -100,8 +100,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -100,8 +100,8 @@ describe('Cache Components Fallback Validation', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page "source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
...@@ -118,8 +118,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -118,8 +118,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page "source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
...@@ -133,8 +133,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -133,8 +133,8 @@ describe('Cache Components Fallback Validation', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page "source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
...@@ -155,8 +155,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -155,8 +155,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout "source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
...@@ -170,8 +170,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -170,8 +170,8 @@ describe('Cache Components Fallback Validation', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout "source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
...@@ -188,8 +188,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -188,8 +188,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout "source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
...@@ -203,8 +203,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -203,8 +203,8 @@ describe('Cache Components Fallback Validation', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout "source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
...@@ -221,8 +221,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -221,8 +221,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout "source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
...@@ -236,8 +236,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -236,8 +236,8 @@ describe('Cache Components Fallback Validation', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout "source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
...@@ -254,8 +254,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -254,8 +254,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout "source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
...@@ -269,8 +269,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -269,8 +269,8 @@ describe('Cache Components Fallback Validation', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout "source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
...@@ -287,8 +287,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -287,8 +287,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout "source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
...@@ -302,8 +302,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -302,8 +302,8 @@ describe('Cache Components Fallback Validation', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout "source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
...@@ -320,8 +320,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -320,8 +320,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) { if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout "source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
...@@ -335,8 +335,8 @@ describe('Cache Components Fallback Validation', () => { ...@@ -335,8 +335,8 @@ describe('Cache Components Fallback Validation', () => {
} else { } else {
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1221", "code": "E1272",
"description": "Next.js encountered runtime data during the initial render.", "description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout "source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -63,7 +63,7 @@ describe('instant-validation-build', () => { ...@@ -63,7 +63,7 @@ describe('instant-validation-build', () => {
) )
expect(extractBuildValidationError(result.cliOutput)) expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"Error: Route "/invalid-missing-suspense-around-runtime": Next.js encountered uncached data during the initial render or a navigation. "Error: Route "/invalid-missing-suspense-around-runtime": Next.js encountered uncached data during prerendering or a navigation.
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience. \`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
......
...@@ -105,7 +105,7 @@ describe('instant validation causes', () => { ...@@ -105,7 +105,7 @@ describe('instant validation causes', () => {
], ],
}, },
], ],
"code": "E1251", "code": "E1271",
"description": "Next.js encountered runtime data during a navigation.", "description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -136,7 +136,7 @@ describe('instant validation causes', () => { ...@@ -136,7 +136,7 @@ describe('instant validation causes', () => {
], ],
}, },
], ],
"code": "E1251", "code": "E1271",
"description": "Next.js encountered runtime data during a navigation.", "description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -167,7 +167,7 @@ describe('instant validation causes', () => { ...@@ -167,7 +167,7 @@ describe('instant validation causes', () => {
], ],
}, },
], ],
"code": "E1251", "code": "E1271",
"description": "Next.js encountered runtime data during a navigation.", "description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -201,7 +201,7 @@ describe('instant validation causes', () => { ...@@ -201,7 +201,7 @@ describe('instant validation causes', () => {
], ],
}, },
], ],
"code": "E1251", "code": "E1271",
"description": "Next.js encountered runtime data during a navigation.", "description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
......
...@@ -60,7 +60,7 @@ describe('instant validation - level error', () => { ...@@ -60,7 +60,7 @@ describe('instant validation - level error', () => {
const browser = await next.browser('/bare') const browser = await next.browser('/bare')
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -90,7 +90,7 @@ describe('instant validation - level error', () => { ...@@ -90,7 +90,7 @@ describe('instant validation - level error', () => {
], ],
}, },
], ],
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -120,7 +120,7 @@ describe('instant validation - level error', () => { ...@@ -120,7 +120,7 @@ describe('instant validation - level error', () => {
], ],
}, },
], ],
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -150,7 +150,7 @@ describe('instant validation - level error', () => { ...@@ -150,7 +150,7 @@ describe('instant validation - level error', () => {
], ],
}, },
], ],
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -177,7 +177,7 @@ describe('instant validation - level error', () => { ...@@ -177,7 +177,7 @@ describe('instant validation - level error', () => {
const browser = await next.browser('/layered') const browser = await next.browser('/layered')
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -197,7 +197,7 @@ describe('instant validation - level error', () => { ...@@ -197,7 +197,7 @@ describe('instant validation - level error', () => {
const result = await prerender('/bare') const result = await prerender('/bare')
expect(extractBuildValidationError(result.cliOutput)) expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"Error: Route "/bare": Next.js encountered uncached data during the initial render or a navigation. "Error: Route "/bare": Next.js encountered uncached data during prerendering or a navigation.
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience. \`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
...@@ -223,7 +223,7 @@ describe('instant validation - level error', () => { ...@@ -223,7 +223,7 @@ describe('instant validation - level error', () => {
const result = await prerender('/explicit-error') const result = await prerender('/explicit-error')
expect(extractBuildValidationError(result.cliOutput)) expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"Error: Route "/explicit-error": Next.js encountered uncached data during the initial render or a navigation. "Error: Route "/explicit-error": Next.js encountered uncached data during prerendering or a navigation.
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience. \`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
...@@ -249,7 +249,7 @@ describe('instant validation - level error', () => { ...@@ -249,7 +249,7 @@ describe('instant validation - level error', () => {
const result = await prerender('/explicit-true') const result = await prerender('/explicit-true')
expect(extractBuildValidationError(result.cliOutput)) expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"Error: Route "/explicit-true": Next.js encountered uncached data during the initial render or a navigation. "Error: Route "/explicit-true": Next.js encountered uncached data during prerendering or a navigation.
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience. \`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
...@@ -288,7 +288,7 @@ describe('instant validation - level error', () => { ...@@ -288,7 +288,7 @@ describe('instant validation - level error', () => {
const result = await prerender('/layered') const result = await prerender('/layered')
expect(extractBuildValidationError(result.cliOutput)) expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"Error: Route "/layered": Next.js encountered uncached data during the initial render or a navigation. "Error: Route "/layered": Next.js encountered uncached data during prerendering or a navigation.
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience. \`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
......
...@@ -79,7 +79,7 @@ describe('instant validation - level manual-error', () => { ...@@ -79,7 +79,7 @@ describe('instant validation - level manual-error', () => {
], ],
}, },
], ],
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -109,7 +109,7 @@ describe('instant validation - level manual-error', () => { ...@@ -109,7 +109,7 @@ describe('instant validation - level manual-error', () => {
], ],
}, },
], ],
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -139,7 +139,7 @@ describe('instant validation - level manual-error', () => { ...@@ -139,7 +139,7 @@ describe('instant validation - level manual-error', () => {
], ],
}, },
], ],
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -180,7 +180,7 @@ describe('instant validation - level manual-error', () => { ...@@ -180,7 +180,7 @@ describe('instant validation - level manual-error', () => {
const result = await prerender('/explicit-error') const result = await prerender('/explicit-error')
expect(extractBuildValidationError(result.cliOutput)) expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"Error: Route "/explicit-error": Next.js encountered uncached data during the initial render or a navigation. "Error: Route "/explicit-error": Next.js encountered uncached data during prerendering or a navigation.
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience. \`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
...@@ -206,7 +206,7 @@ describe('instant validation - level manual-error', () => { ...@@ -206,7 +206,7 @@ describe('instant validation - level manual-error', () => {
const result = await prerender('/explicit-true') const result = await prerender('/explicit-true')
expect(extractBuildValidationError(result.cliOutput)) expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"Error: Route "/explicit-true": Next.js encountered uncached data during the initial render or a navigation. "Error: Route "/explicit-true": Next.js encountered uncached data during prerendering or a navigation.
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience. \`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
......
...@@ -60,7 +60,7 @@ describe('instant validation - level warning', () => { ...@@ -60,7 +60,7 @@ describe('instant validation - level warning', () => {
const browser = await next.browser('/bare') const browser = await next.browser('/bare')
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -90,7 +90,7 @@ describe('instant validation - level warning', () => { ...@@ -90,7 +90,7 @@ describe('instant validation - level warning', () => {
], ],
}, },
], ],
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -120,7 +120,7 @@ describe('instant validation - level warning', () => { ...@@ -120,7 +120,7 @@ describe('instant validation - level warning', () => {
], ],
}, },
], ],
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -150,7 +150,7 @@ describe('instant validation - level warning', () => { ...@@ -150,7 +150,7 @@ describe('instant validation - level warning', () => {
], ],
}, },
], ],
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -177,7 +177,7 @@ describe('instant validation - level warning', () => { ...@@ -177,7 +177,7 @@ describe('instant validation - level warning', () => {
const browser = await next.browser('/layered') const browser = await next.browser('/layered')
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1249", "code": "E1264",
"description": "Next.js encountered uncached data during a navigation.", "description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
...@@ -202,7 +202,7 @@ describe('instant validation - level warning', () => { ...@@ -202,7 +202,7 @@ describe('instant validation - level warning', () => {
const result = await prerender('/explicit-error') const result = await prerender('/explicit-error')
expect(extractBuildValidationError(result.cliOutput)) expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"Error: Route "/explicit-error": Next.js encountered uncached data during the initial render or a navigation. "Error: Route "/explicit-error": Next.js encountered uncached data during prerendering or a navigation.
\`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience. \`fetch(...)\` or \`connection()\` accessed outside of \`<Suspense>\` prevents the route from being prerendered or the navigation from being instant, leading to a slower user experience.
......
...@@ -45,8 +45,8 @@ describe('instant validation', () => { ...@@ -45,8 +45,8 @@ describe('instant validation', () => {
await browser.elementByCss('main') await browser.elementByCss('main')
await expect(browser).toDisplayCollapsedRedbox(` await expect(browser).toDisplayCollapsedRedbox(`
{ {
"code": "E1220", "code": "E1265",
"description": "Next.js encountered uncached data during the initial render.", "description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server", "environmentLabel": "Server",
"label": "Instant", "label": "Instant",
"source": "app/blocking-page-below-static/page.tsx (6:19) @ Page "source": "app/blocking-page-below-static/page.tsx (6:19) @ Page
...@@ -69,7 +69,7 @@ describe('instant validation', () => { ...@@ -69,7 +69,7 @@ describe('instant validation', () => {
}) })
it('errors during build', () => { it('errors during build', () => {
expect(didBuildError).toBe(true) expect(didBuildError).toBe(true)
expect(next.cliOutput).toContain('during the initial render') expect(next.cliOutput).toContain('during prerendering')
}) })
} }
}) })
......
...@@ -71,13 +71,14 @@ describe('build-output-prerender', () => { ...@@ -71,13 +71,14 @@ describe('build-output-prerender', () => {
if (isTurbopack) { if (isTurbopack) {
// TODO(veil): Why is the location incomplete unless we enable --no-mangling? // TODO(veil): Why is the location incomplete unless we enable --no-mangling?
expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(`
"Error: Route "/client": Next.js encountered \`new Date()\` in a Client Component. "Error: Route "/client": Next.js encountered the unstable value \`new Date()\` in a Client Component.
This value would be evaluated during the prerender and fixed at build time, instead of recomputed on each visit. This value would be evaluated during the prerender, instead of recomputed on each visit.
Ways to fix this: Ways to fix this:
- Wrap the Client Component in \`<Suspense fallback={...}>\` - Wrap the Client Component in \`<Suspense fallback={...}>\`
- Move the read into a \`useEffect\` or event handler - Move the read into a \`useEffect\` or event handler
- If the value is for telemetry, use a timing API such as \`performance.now()\`
Learn more: https://nextjs.org/docs/messages/next-prerender-current-time-client Learn more: https://nextjs.org/docs/messages/next-prerender-current-time-client
at <unknown> (app/client/page.tsx:4:28) at <unknown> (app/client/page.tsx:4:28)
...@@ -95,13 +96,14 @@ describe('build-output-prerender', () => { ...@@ -95,13 +96,14 @@ describe('build-output-prerender', () => {
`) `)
} else { } else {
expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(`
"Error: Route "/client": Next.js encountered \`new Date()\` in a Client Component. "Error: Route "/client": Next.js encountered the unstable value \`new Date()\` in a Client Component.
This value would be evaluated during the prerender and fixed at build time, instead of recomputed on each visit. This value would be evaluated during the prerender, instead of recomputed on each visit.
Ways to fix this: Ways to fix this:
- Wrap the Client Component in \`<Suspense fallback={...}>\` - Wrap the Client Component in \`<Suspense fallback={...}>\`
- Move the read into a \`useEffect\` or event handler - Move the read into a \`useEffect\` or event handler
- If the value is for telemetry, use a timing API such as \`performance.now()\`
Learn more: https://nextjs.org/docs/messages/next-prerender-current-time-client Learn more: https://nextjs.org/docs/messages/next-prerender-current-time-client
at x (<next-dist-dir>) at x (<next-dist-dir>)
...@@ -210,13 +212,14 @@ describe('build-output-prerender', () => { ...@@ -210,13 +212,14 @@ describe('build-output-prerender', () => {
it('shows all prerender errors with readable stacks and code frames', async () => { it('shows all prerender errors with readable stacks and code frames', async () => {
if (isTurbopack) { if (isTurbopack) {
expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(`
"Error: Route "/client": Next.js encountered \`new Date()\` in a Client Component. "Error: Route "/client": Next.js encountered the unstable value \`new Date()\` in a Client Component.
This value would be evaluated during the prerender and fixed at build time, instead of recomputed on each visit. This value would be evaluated during the prerender, instead of recomputed on each visit.
Ways to fix this: Ways to fix this:
- Wrap the Client Component in \`<Suspense fallback={...}>\` - Wrap the Client Component in \`<Suspense fallback={...}>\`
- Move the read into a \`useEffect\` or event handler - Move the read into a \`useEffect\` or event handler
- If the value is for telemetry, use a timing API such as \`performance.now()\`
Learn more: https://nextjs.org/docs/messages/next-prerender-current-time-client Learn more: https://nextjs.org/docs/messages/next-prerender-current-time-client
at Page (app/client/page.tsx:4:28) at Page (app/client/page.tsx:4:28)
...@@ -228,7 +231,7 @@ describe('build-output-prerender', () => { ...@@ -228,7 +231,7 @@ describe('build-output-prerender', () => {
6 | 6 |
To debug the issue, start the app in development mode by running \`next dev\`, then open "/client" in your browser to investigate the error. To debug the issue, start the app in development mode by running \`next dev\`, then open "/client" in your browser to investigate the error.
Error occurred prerendering page "/client". Read more: https://nextjs.org/docs/messages/prerender-error Error occurred prerendering page "/client". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Route "/server": Next.js encountered \`Math.random()\` without an explicit rendering intent. Error: Route "/server": Next.js encountered the unstable value \`Math.random()\` while prerendering.
This value can change between renders, so it must be either prerendered or computed later. This value can change between renders, so it must be either prerendered or computed later.
...@@ -256,13 +259,14 @@ describe('build-output-prerender', () => { ...@@ -256,13 +259,14 @@ describe('build-output-prerender', () => {
} else { } else {
// TODO(veil): Bundler protocols should not appear in stackframes. // TODO(veil): Bundler protocols should not appear in stackframes.
expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(`
"Error: Route "/client": Next.js encountered \`new Date()\` in a Client Component. "Error: Route "/client": Next.js encountered the unstable value \`new Date()\` in a Client Component.
This value would be evaluated during the prerender and fixed at build time, instead of recomputed on each visit. This value would be evaluated during the prerender, instead of recomputed on each visit.
Ways to fix this: Ways to fix this:
- Wrap the Client Component in \`<Suspense fallback={...}>\` - Wrap the Client Component in \`<Suspense fallback={...}>\`
- Move the read into a \`useEffect\` or event handler - Move the read into a \`useEffect\` or event handler
- If the value is for telemetry, use a timing API such as \`performance.now()\`
Learn more: https://nextjs.org/docs/messages/next-prerender-current-time-client Learn more: https://nextjs.org/docs/messages/next-prerender-current-time-client
at Page (webpack:///app/client/page.tsx:4:28) at Page (webpack:///app/client/page.tsx:4:28)
...@@ -275,7 +279,7 @@ describe('build-output-prerender', () => { ...@@ -275,7 +279,7 @@ describe('build-output-prerender', () => {
6 | 6 |
To debug the issue, start the app in development mode by running \`next dev\`, then open "/client" in your browser to investigate the error. To debug the issue, start the app in development mode by running \`next dev\`, then open "/client" in your browser to investigate the error.
Error occurred prerendering page "/client". Read more: https://nextjs.org/docs/messages/prerender-error Error occurred prerendering page "/client". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Route "/server": Next.js encountered \`Math.random()\` without an explicit rendering intent. Error: Route "/server": Next.js encountered the unstable value \`Math.random()\` while prerendering.
This value can change between renders, so it must be either prerendered or computed later. This value can change between renders, so it must be either prerendered or computed later.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment