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 = `
.error-overlay-dialog-scroll {
overflow-y: auto;
scrollbar-gutter: stable;
height: 100%;
}
`
......@@ -16,7 +16,7 @@ export type FixCardIcon =
| 'database'
| 'history'
| 'layout'
| 'octagon'
| 'loading'
| 'pointer-click'
| 'server-stack'
| 'timer'
......@@ -28,7 +28,7 @@ export const FIX_CARD_GROUPS: Record<
> = {
stream: { label: 'Stream', color: 'blue', icon: 'align-left' },
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' },
static: { label: 'Static', color: 'gray', icon: 'zap' },
dynamic: { label: 'Dynamic', color: 'blue', icon: 'server-stack' },
......@@ -77,7 +77,7 @@ const runtimeCards: FixCard[] = [
},
{
id: 'prerender-known-params',
title: 'Prerender known params',
title: 'For known params, prerender',
group: 'cache',
link: 'https://nextjs.org/docs/messages/blocking-route#prerender-known-params',
snippets: [
......@@ -162,7 +162,7 @@ const metadataRuntimeCards: FixCard[] = [
},
{
id: 'render-page-at-request-time',
title: 'Generate the page on every request',
title: 'Mark the route as dynamic',
group: 'dynamic',
link: 'https://nextjs.org/docs/messages/next-prerender-dynamic-metadata#render-page-at-request-time',
snippets: [
......@@ -186,7 +186,7 @@ const metadataDynamicCards: FixCard[] = [
},
{
id: 'render-page-at-request-time',
title: 'Generate the page on every request',
title: 'Mark the route as dynamic',
group: 'dynamic',
link: 'https://nextjs.org/docs/messages/next-prerender-dynamic-metadata#render-page-at-request-time',
snippets: [
......@@ -210,17 +210,6 @@ const viewportRuntimeCards: FixCard[] = [
{ 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',
title: 'Allow blocking route',
......@@ -245,17 +234,6 @@ const viewportDynamicCards: FixCard[] = [
{ 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',
title: 'Allow blocking route',
......@@ -300,8 +278,8 @@ const syncMathCards: FixCard[] = [
link: 'https://nextjs.org/docs/messages/next-prerender-random#render-on-the-client',
snippets: [
{ text: '"use client"', highlight: true },
{ text: 'const [id] = useState(() => Math.random())' },
{ text: 'return <Item id={id} />' },
{ text: '// runs in the browser' },
{ text: 'const id = Math.random()' },
],
},
]
......@@ -336,13 +314,13 @@ const syncDateCards: FixCard[] = [
link: 'https://nextjs.org/docs/messages/next-prerender-current-time#render-on-the-client',
snippets: [
{ text: '"use client"', highlight: true },
{ text: 'useEffect(() => setT(Date.now()), [])' },
{ text: 'return <Banner time={t} />' },
{ text: '// runs in the browser' },
{ text: 'const t = Date.now()' },
],
},
{
id: 'measure-elapsed-time',
title: 'Measure elapsed time',
title: 'For telemetry, use a timing API',
group: 'measure',
link: 'https://nextjs.org/docs/messages/next-prerender-current-time#measure-elapsed-time',
snippets: [
......@@ -383,8 +361,8 @@ const syncCryptoCards: FixCard[] = [
link: 'https://nextjs.org/docs/messages/next-prerender-crypto#render-on-the-client',
snippets: [
{ text: '"use client"', highlight: true },
{ text: 'const [id] = useState(() => crypto.randomUUID())' },
{ text: 'return <Token id={id} />' },
{ text: '// runs in the browser' },
{ text: 'const id = crypto.randomUUID()' },
],
},
]
......@@ -416,7 +394,7 @@ const syncClientDateCards: FixCard[] = [
},
{
id: 'measure-elapsed-time',
title: 'Measure elapsed time',
title: 'For telemetry, use a timing API',
group: 'measure',
link: 'https://nextjs.org/docs/messages/next-prerender-current-time-client#measure-elapsed-time',
snippets: [
......
......@@ -3,7 +3,7 @@ import {
FixCardDatabaseIcon,
FixCardHistoryIcon,
FixCardLayoutIcon,
FixCardOctagonIcon,
FixCardLoadingIcon,
FixCardPointerClickIcon,
FixCardServerStackIcon,
FixCardTimerIcon,
......@@ -41,8 +41,8 @@ function getCardIcon(icon: FixCardIcon) {
return <FixCardDatabaseIcon />
case 'timer':
return <FixCardTimerIcon />
case 'octagon':
return <FixCardOctagonIcon />
case 'loading':
return <FixCardLoadingIcon />
case 'zap':
return <FixCardZapIcon />
case 'layout':
......@@ -237,7 +237,6 @@ export const INSTANT_GUIDANCE_STYLES = css`
display: flex;
flex-direction: column;
min-width: 0;
overflow: hidden;
position: relative;
text-decoration: none;
}
......@@ -254,6 +253,15 @@ export const INSTANT_GUIDANCE_STYLES = css`
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 {
outline: var(--focus-ring);
outline-offset: 2px;
......@@ -333,6 +341,7 @@ export const INSTANT_GUIDANCE_STYLES = css`
line-height: 1.5;
margin: 0;
margin-left: -1px;
margin-bottom: -1px;
padding: 14px 16px;
width: calc(100% + 2px);
white-space: pre;
......@@ -346,11 +355,6 @@ export const INSTANT_GUIDANCE_STYLES = css`
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] {
display: block;
color: var(--color-gray-800);
......
......@@ -325,7 +325,7 @@ export function isSyncIOClientError(message: string): boolean {
// Detects errors emitted during navigation-phase instant validation: body
// errors from `createRuntimeBodyErrorInNavigation` /
// `createDynamicBodyErrorInNavigation` (SSR factories instead say "during
// the initial render"), and validation errors from
// prerendering"), and validation errors from
// `trackDynamicHoleInNavigation` / `getNavigationDisallowedDynamicReasons`.
export function isBlockingRouteInNavError(message: string): boolean {
return (
......@@ -559,10 +559,10 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\
errorDetails.variant === 'runtime'
? errorDetails.inNavigation
? '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
? '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={
<InstantHeaderExplanation
......@@ -684,8 +684,8 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\
errorType={errorType}
errorMessage={
<>
Next.js encountered <code>{errorDetails.cause}</code> without an
explicit rendering intent.
Next.js encountered the unstable value{' '}
<code>{errorDetails.cause}</code> while prerendering.
</>
}
headerChildren={
......@@ -724,13 +724,13 @@ Next.js version: ${props.versionInfo.installed} (${process.env.__NEXT_BUNDLER})\
errorType={errorType}
errorMessage={
<>
Next.js encountered <code>{errorDetails.cause}</code> in a Client
Component.
Next.js encountered the unstable value{' '}
<code>{errorDetails.cause}</code> in a Client Component.
</>
}
headerChildren={
<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]}
/>
}
......
......@@ -46,7 +46,7 @@ export function FixCardHistoryIcon() {
)
}
export function FixCardOctagonIcon() {
export function FixCardLoadingIcon() {
return (
<svg
width="16"
......@@ -55,12 +55,23 @@ export function FixCardOctagonIcon() {
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill="currentColor"
fillRule="evenodd"
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"
/>
{Array.from({ length: 12 }, (_, index) => {
const angle = index * 30
const opacity = 1 - index * 0.05
return (
<circle
key={angle}
cx="8"
cy="2.3"
r="0.9"
fill="currentColor"
stroke="none"
opacity={opacity}
transform={`rotate(${angle} 8 8)`}
/>
)
})}
</svg>
)
}
......
export function createRuntimeBodyError(route: string): Error {
return new Error(
`Route "${route}": Next.js encountered runtime data during the initial render.\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` +
`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 the page load and leading to a slower user experience.\n\n` +
`Ways to fix this:\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` +
`Learn more: https://nextjs.org/docs/messages/blocking-route`
)
......@@ -12,8 +12,8 @@ export function createRuntimeBodyError(route: string): Error {
export function createDynamicBodyError(route: string): Error {
return new Error(
`Route "${route}": Next.js encountered uncached data during the initial render.\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` +
`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 the page load and leading to a slower user experience.\n\n` +
`Ways to fix this:\n` +
` - Cache the data access with \`"use cache"\`\n` +
` - Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
......@@ -24,11 +24,11 @@ export function createDynamicBodyError(route: string): Error {
export function createRuntimeBodyErrorInNavigation(route: string): 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` +
`Ways to fix this:\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` +
`Learn more: https://nextjs.org/docs/messages/blocking-route`
)
......@@ -36,7 +36,7 @@ export function createRuntimeBodyErrorInNavigation(route: string): Error {
export function createDynamicBodyErrorInNavigation(route: string): 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` +
`Ways to fix this:\n` +
` - Cache the data access with \`"use cache"\`\n` +
......@@ -53,12 +53,12 @@ export function createDynamicBodyErrorInNavigation(route: string): Error {
*/
export function createDynamicOrRuntimeBodyError(route: string): Error {
return new Error(
`Route "${route}": Next.js encountered uncached or runtime data during the initial render.\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` +
`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 the page load and leading to a slower user experience.\n\n` +
`Ways to fix this:\n` +
` - Cache the data access with \`"use cache"\`\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` +
`Learn more: https://nextjs.org/docs/messages/blocking-route`
)
......@@ -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` +
`Ways to fix this:\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` +
`Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport`
)
......@@ -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` +
`Ways to fix this:\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` +
`Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport`
)
......@@ -122,7 +120,6 @@ export function createDynamicOrRuntimeViewportError(route: string): Error {
`Ways to fix this:\n` +
` - Use a static viewport export instead of \`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` +
`Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport`
)
......
......@@ -20,7 +20,7 @@ const SYNC_IO_RUNTIME_DOCS: Record<SyncIOApiType, string> = {
function elapsedTimeBullet(type: SyncIOApiType): string {
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(
docsUrl: string
): 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` +
`Ways to fix this:\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(
type: SyncIOApiType
): Error {
return new Error(
`Route "${route}": Next.js encountered ${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` +
`Route "${route}": Next.js encountered the unstable value ${expression} in a Client Component.\n\n` +
`This value would be evaluated during the prerender, instead of recomputed on each visit.\n\n` +
`Ways to fix this:\n` +
` - Wrap the Client Component in \`<Suspense fallback={...}>\`\n` +
` - Move the read into a \`useEffect\` or event handler\n` +
elapsedTimeBullet(type) +
`\n` +
`Learn more: ${SYNC_IO_CLIENT_DOCS[type]}`
)
......
......@@ -75,12 +75,12 @@ describe('Cache Components Dev Errors', () => {
await openRedbox(browser)
desc = await getRedboxDescription(browser)
expect(desc).toContain('during the initial render')
expect(desc).toContain('during prerendering')
await browser.refresh()
await openRedbox(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', () => {
// soft-navigating to the page (see test below).
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1242",
"description": "Next.js encountered Math.random() without an explicit rendering intent.",
"code": "E1261",
"description": "Next.js encountered the unstable value Math.random() while prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/error/page.tsx (2:23) @ Page
......@@ -51,8 +51,8 @@ describe('Cache Components Dev Errors', () => {
// TODO: React should not include the anon stack in the Owner Stack.
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1242",
"description": "Next.js encountered Math.random() without an explicit rendering intent.",
"code": "E1261",
"description": "Next.js encountered the unstable value Math.random() while prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/error/page.tsx (2:23) @ Page
......@@ -98,8 +98,8 @@ describe('Cache Components Dev Errors', () => {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1220",
"description": "Next.js encountered uncached data during the initial render.",
"code": "E1265",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/no-accessed-data/page.js (2:9) @ Page
......
......@@ -52,8 +52,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
......@@ -67,8 +67,8 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
......@@ -85,8 +85,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
......@@ -100,8 +100,8 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
......@@ -118,8 +118,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
......@@ -133,8 +133,8 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
......@@ -155,8 +155,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
......@@ -170,8 +170,8 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
......@@ -188,8 +188,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
......@@ -203,8 +203,8 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
......@@ -221,8 +221,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
......@@ -236,8 +236,8 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
......@@ -254,8 +254,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
......@@ -269,8 +269,8 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
......@@ -287,8 +287,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
......@@ -302,8 +302,8 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
......@@ -320,8 +320,8 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
......@@ -335,8 +335,8 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1221",
"description": "Next.js encountered runtime data during the initial render.",
"code": "E1272",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"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', () => {
)
expect(extractBuildValidationError(result.cliOutput))
.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.
......
......@@ -105,7 +105,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1251",
"code": "E1271",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -136,7 +136,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1251",
"code": "E1271",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -167,7 +167,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1251",
"code": "E1271",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -201,7 +201,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1251",
"code": "E1271",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......
......@@ -60,7 +60,7 @@ describe('instant validation - level error', () => {
const browser = await next.browser('/bare')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -90,7 +90,7 @@ describe('instant validation - level error', () => {
],
},
],
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -120,7 +120,7 @@ describe('instant validation - level error', () => {
],
},
],
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -150,7 +150,7 @@ describe('instant validation - level error', () => {
],
},
],
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -177,7 +177,7 @@ describe('instant validation - level error', () => {
const browser = await next.browser('/layered')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -197,7 +197,7 @@ describe('instant validation - level error', () => {
const result = await prerender('/bare')
expect(extractBuildValidationError(result.cliOutput))
.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.
......@@ -223,7 +223,7 @@ describe('instant validation - level error', () => {
const result = await prerender('/explicit-error')
expect(extractBuildValidationError(result.cliOutput))
.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.
......@@ -249,7 +249,7 @@ describe('instant validation - level error', () => {
const result = await prerender('/explicit-true')
expect(extractBuildValidationError(result.cliOutput))
.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.
......@@ -288,7 +288,7 @@ describe('instant validation - level error', () => {
const result = await prerender('/layered')
expect(extractBuildValidationError(result.cliOutput))
.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.
......
......@@ -79,7 +79,7 @@ describe('instant validation - level manual-error', () => {
],
},
],
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -109,7 +109,7 @@ describe('instant validation - level manual-error', () => {
],
},
],
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -139,7 +139,7 @@ describe('instant validation - level manual-error', () => {
],
},
],
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -180,7 +180,7 @@ describe('instant validation - level manual-error', () => {
const result = await prerender('/explicit-error')
expect(extractBuildValidationError(result.cliOutput))
.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.
......@@ -206,7 +206,7 @@ describe('instant validation - level manual-error', () => {
const result = await prerender('/explicit-true')
expect(extractBuildValidationError(result.cliOutput))
.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.
......
......@@ -60,7 +60,7 @@ describe('instant validation - level warning', () => {
const browser = await next.browser('/bare')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -90,7 +90,7 @@ describe('instant validation - level warning', () => {
],
},
],
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -120,7 +120,7 @@ describe('instant validation - level warning', () => {
],
},
],
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -150,7 +150,7 @@ describe('instant validation - level warning', () => {
],
},
],
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -177,7 +177,7 @@ describe('instant validation - level warning', () => {
const browser = await next.browser('/layered')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1249",
"code": "E1264",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -202,7 +202,7 @@ describe('instant validation - level warning', () => {
const result = await prerender('/explicit-error')
expect(extractBuildValidationError(result.cliOutput))
.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.
......
......@@ -45,8 +45,8 @@ describe('instant validation', () => {
await browser.elementByCss('main')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1220",
"description": "Next.js encountered uncached data during the initial render.",
"code": "E1265",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Instant",
"source": "app/blocking-page-below-static/page.tsx (6:19) @ Page
......@@ -69,7 +69,7 @@ describe('instant validation', () => {
})
it('errors during build', () => {
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', () => {
if (isTurbopack) {
// TODO(veil): Why is the location incomplete unless we enable --no-mangling?
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:
- Wrap the Client Component in \`<Suspense fallback={...}>\`
- 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
at <unknown> (app/client/page.tsx:4:28)
......@@ -95,13 +96,14 @@ describe('build-output-prerender', () => {
`)
} else {
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:
- Wrap the Client Component in \`<Suspense fallback={...}>\`
- 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
at x (<next-dist-dir>)
......@@ -210,13 +212,14 @@ describe('build-output-prerender', () => {
it('shows all prerender errors with readable stacks and code frames', async () => {
if (isTurbopack) {
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:
- Wrap the Client Component in \`<Suspense fallback={...}>\`
- 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
at Page (app/client/page.tsx:4:28)
......@@ -228,7 +231,7 @@ describe('build-output-prerender', () => {
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.
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.
......@@ -256,13 +259,14 @@ describe('build-output-prerender', () => {
} else {
// TODO(veil): Bundler protocols should not appear in stackframes.
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:
- Wrap the Client Component in \`<Suspense fallback={...}>\`
- 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
at Page (webpack:///app/client/page.tsx:4:28)
......@@ -275,7 +279,7 @@ describe('build-output-prerender', () => {
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.
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.
......
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