Unverified Commit e2b0d2ea authored by Josh Story's avatar Josh Story Committed by GitHub

Instant Insights: When unable to complete validation provide a filename for the…

Instant Insights: When unable to complete validation provide a filename for the unvalidated boundary (#93770)

The error message previously did not say which parallel route slot
couldn't be validated. Now it poitns to the nearest segment below the
validation boundary. The idea is you go look abive this and figure out
if it is intentional that this segment isn't rendered in the current
context. If so you can ignored the warning (it should ideally not even
be presented as a normal error) but if it is unintentional you
investigate why you aren't SSRing this slot or you mark the slot as
intentionally blocking so it doesn't get validated.
parent 20892dd4
---
title: An expected segment was not rendered during instant UI validation
---
## Why This Error Occurred
Next.js attempted to validate that navigation to the affected route is able to be rendered instantly without waiting on a server request or data loading.
In this instance Next.js was unable to verify that the navigation would be instant because something prevented the necessary page data from rendering during validation.
## Common Causes
### A parent layout conditionally omits a parallel slot
If a layout receives multiple slot props (e.g. `children`, `@modal`, `@sidebar`) but only renders some of them based on a condition, the omitted slot's content never renders.
```tsx
// app/dashboard/layout.tsx
export default function Layout({
children,
modal,
}: {
children: React.ReactNode
modal: React.ReactNode
}) {
return (
<main>
{children}
{
// `modal` is only rendered conditionally.
showModal ? modal : null
}
</main>
)
}
```
### A client component does not render its children during SSR
If a client component does not render during SSR, any segments it would have rendered as children cannot be validated for instant UI.
```tsx
import dynamic from 'next/dynamic'
// This component and its children will not render during SSR.
const ClientOnly = dynamic(() => import('./my-component'), { ssr: false })
export default async function Layout({ children }) {
// The children of this layout won't appear in the SSR HTML
// but can render fine on client navigation
return <ClientOnly>{children}</ClientOnly>
}
```
## How to Fix It
### If the missing segment is intentional
If you expect this segment to sometimes not render (for example, a modal slot that only appears on certain routes), you can opt it out of instant UI validation:
```tsx
// app/dashboard/@modal/page.tsx
export const unstable_instant = false
export default function ModalPage() {
// ...
}
```
### If the missing segment is unintentional
Check the parent layouts above the reported segment. Make sure every layout renders its slot props (`children` and any named parallel routes). If a client component wraps the segment, ensure it renders its children during SSR.
......@@ -1243,5 +1243,6 @@
"1242": "Route \"%s\": Next.js encountered %s without an explicit rendering intent.\\n\\nThis value can change between renders, so it must be either prerendered or computed later.\\n\\nWays to fix this:\\n - Render at request time by adding a dynamic data access (e.g. \\`await connection()\\`) before this call\\n - Prerender and cache the value with \\`\"use cache\"\\`\\n - Render the value on the client with \\`\"use client\"\\`\\n%s\\nLearn more: %s",
"1243": "This \"use cache\" has a dynamic cache life that was propagated to its parent.",
"1244": "A \"use cache\" with short \\`expire\\` (under 5 minutes) is nested inside another \"use cache\" that has no explicit \\`cacheLife\\`, which is not allowed during prerendering. Add \\`cacheLife()\\` to the outer \"use cache\" to choose whether it should be prerendered (with longer \\`expire\\`) or remain dynamic (with short \\`expire\\`). Read more: https://nextjs.org/docs/messages/nested-use-cache-no-explicit-cachelife",
"1245": "A \"use cache\" with zero \\`revalidate\\` is nested inside another \"use cache\" that has no explicit \\`cacheLife\\`, which is not allowed during prerendering. Add \\`cacheLife()\\` to the outer \"use cache\" to choose whether it should be prerendered (with non-zero \\`revalidate\\`) or remain dynamic (with zero \\`revalidate\\`). Read more: https://nextjs.org/docs/messages/nested-use-cache-no-explicit-cachelife"
"1245": "A \"use cache\" with zero \\`revalidate\\` is nested inside another \"use cache\" that has no explicit \\`cacheLife\\`, which is not allowed during prerendering. Add \\`cacheLife()\\` to the outer \"use cache\" to choose whether it should be prerendered (with non-zero \\`revalidate\\`) or remain dynamic (with zero \\`revalidate\\`). Read more: https://nextjs.org/docs/messages/nested-use-cache-no-explicit-cachelife",
"1246": "Could not validate instant UI because an expected segment was not rendered."
}
......@@ -6165,8 +6165,8 @@ async function validateInstantConfigs(
if (previousBoundaryState) {
// We're doing a followup render to better discriminate error types
useRuntimeStageForPartialSegments = true
for (const id of previousBoundaryState.requiredIds) {
boundaryState.requiredIds.add(id)
for (const [id, filePath] of previousBoundaryState.requiredIds) {
boundaryState.requiredIds.set(id, filePath)
}
}
......@@ -6422,13 +6422,15 @@ async function validateInstantConfigs(
// There was no validation to perform at this level
debug?.(` No config at depth ${depth}+${currentGroupDepth}, skipping.`)
} else {
// Something prevented this level from fully validating but there were no detected errors
if (impairedValidation === null) {
// Something prevented this level from fully validating but there
// were no detected errors. Always overwrite — prefer the
// shallowest deferred fallback. If a high-level layout drops
// children, everything below is unreachable; the shallowest
// unrendered segment is closest to the actual cause.
impairedValidation = result
}
}
}
}
if (impairedValidation) {
debug?.(
......
......@@ -1449,10 +1449,36 @@ export function getNavigationDisallowedDynamicReasons(
const { thrownErrorsOutsideBoundary } = dynamicValidation
const rootInstantStack = dynamicValidation.slotStacks[0]
if (thrownErrorsOutsideBoundary.length === 0) {
const message = `Route "${workStore.route}": Could not validate \`unstable_instant\` because the target segment was prevented from rendering for an unknown reason.`
const error = rootInstantStack !== null ? rootInstantStack() : new Error()
error.name = 'Error'
error.message = message
const missingFiles: string[] = []
for (const [id, filePaths] of boundaryState.requiredIds) {
if (!boundaryState.renderedIds.has(id)) {
for (const filePath of filePaths) {
let normalized = filePath
.replace(/^\[project\][\\/]?/, '')
.replace(process.cwd() + '/', '')
.replace(process.cwd() + '\\', '')
missingFiles.push(normalized)
}
}
}
missingFiles.sort()
let message = `Could not validate instant UI because an expected segment was not rendered.`
if (missingFiles.length > 0) {
const label =
missingFiles.length === 1
? 'Unrendered segment'
: 'Unrendered segments'
message +=
`\n\n${label}:\n${missingFiles.map((p) => ` ${p}`).join('\n')}` +
`\n\nRoute: ${workStore.route}` +
`\n\nThis can happen when you conditionally render a parallel route, for instance a login page when a user is logged out.` +
`\nThis can happen when a client component opts out of rendering during SSR.` +
`\n\nYou can mark this layout as not requiring instant UI with \`export const unstable_instant = false\` if you want to silence this warning.` +
`\n\nLearn more: https://nextjs.org/docs/messages/unrendered-instant-segment`
} else {
message += `\n\nRoute: ${workStore.route}`
}
const error = new Error(message)
return error
} else if (thrownErrorsOutsideBoundary.length === 1) {
const message = `Route "${workStore.route}": Could not validate \`unstable_instant\` because the target segment was prevented from rendering, likely due to the following error.`
......
export type ValidationBoundaryTracking = {
requiredIds: Set<string>
/**
* Map from boundary id (the SegmentPath where a validation boundary is
* placed) to the file paths of modules inside that boundary's subtree.
* When the boundary spans multiple parallel slots, each slot contributes
* its own first-found module path so all unrendered segments can be
* reported together.
*/
requiredIds: Map<string, string[]>
renderedIds: Set<string>
}
export function createValidationBoundaryTracking(): ValidationBoundaryTracking {
return {
requiredIds: new Set(),
requiredIds: new Map(),
renderedIds: new Set(),
}
}
......@@ -13,7 +20,7 @@ export function createValidationBoundaryTracking(): ValidationBoundaryTracking {
export function allRequiredBoundariesRendered(
state: ValidationBoundaryTracking
): boolean {
for (const id of state.requiredIds) {
for (const id of state.requiredIds.keys()) {
if (!state.renderedIds.has(id)) {
return false
}
......
......@@ -782,6 +782,13 @@ type TreeResult = {
seedData: CacheNodeSeedData
requiresInstantUI: boolean
createInstantStack: (() => Error) | null
/** First module file path encountered (DFS) inside this subtree,
* or null if unavailable. The boundary's own segment may not own a
* layout/page module (e.g. a directory whose page lives in a
* __PAGE__ child), so we propagate the first one we find upward.
* Surfaced in the missing-boundary fallback message as a pointer
* to "something inside the subtree that didn't render". */
firstModFilePath: string | null
/** How deep in the tree the config was found. Higher = more specific.
* Used to prefer deeper configs over shallower ones when multiple
* slots have configs. */
......@@ -1063,6 +1070,12 @@ export async function createCombinedPayloadAtDepth(
let requiresInstantUI = false
let createInstantStack: (() => Error) | null = null
let bestConfigDepth = -1
// Collect the first mod file path from each slot's subtree.
// Don't include the boundary segment's own layout/page — that
// file DID render (it wraps the boundary). What didn't render
// is the content inside the children slots.
const slotModFilePaths: string[] = []
let firstModFilePath: string | null = null
for (const parallelRouteKey in parallelRoutes) {
const result = await buildNewTreeSeedData(
......@@ -1074,6 +1087,12 @@ export async function createCombinedPayloadAtDepth(
)
slotResults.set(parallelRouteKey, result)
slots[parallelRouteKey] = result.seedData
if (result.firstModFilePath !== null) {
slotModFilePaths.push(result.firstModFilePath)
if (firstModFilePath === null) {
firstModFilePath = result.firstModFilePath
}
}
if (result.requiresInstantUI) {
requiresInstantUI = true
if (
......@@ -1091,7 +1110,7 @@ export async function createCombinedPayloadAtDepth(
// instant config. Unconfigured slot subtrees are allowed to not
// render (e.g. conditionally excluded by a layout).
if (requiresInstantUI) {
boundaryState.requiredIds.add(path)
boundaryState.requiredIds.set(path, slotModFilePaths)
}
wrapSlotsWithMarkers(slots, slotResults)
......@@ -1100,6 +1119,7 @@ export async function createCombinedPayloadAtDepth(
seedData: getCacheNodeSeedDataFromSegment(finalSegmentData, slots),
requiresInstantUI,
createInstantStack,
firstModFilePath,
configDepth: bestConfigDepth,
}
}
......@@ -1110,6 +1130,7 @@ export async function createCombinedPayloadAtDepth(
let requiresInstantUI = false
let createInstantStack: (() => Error) | null = null
let bestConfigDepth = -1
let firstModFilePath: string | null = null
for (const parallelRouteKey in parallelRoutes) {
const result = await buildSharedTreeSeedData(
parallelRoutes[parallelRouteKey],
......@@ -1120,6 +1141,9 @@ export async function createCombinedPayloadAtDepth(
)
slotResults.set(parallelRouteKey, result)
slots[parallelRouteKey] = result.seedData
if (firstModFilePath === null) {
firstModFilePath = result.firstModFilePath
}
if (result.requiresInstantUI) {
requiresInstantUI = true
if (
......@@ -1139,6 +1163,7 @@ export async function createCombinedPayloadAtDepth(
seedData: getCacheNodeSeedDataFromSegment(segmentData, slots),
requiresInstantUI,
createInstantStack,
firstModFilePath,
configDepth: bestConfigDepth,
}
}
......@@ -1151,7 +1176,9 @@ export async function createCombinedPayloadAtDepth(
segmentDepth: number
): Promise<TreeResult> {
const { parallelRoutes } = parseLoaderTree(lt)
const { mod: layoutOrPageMod } = await getLayoutOrPageModule(lt)
const { mod: layoutOrPageMod, filePath: layoutOrPageFilePath } =
await getLayoutOrPageModule(lt)
const localModFilePath: string | null = layoutOrPageFilePath ?? null
const segment = getSegment(lt)
const path: SegmentPath =
......@@ -1237,6 +1264,7 @@ export async function createCombinedPayloadAtDepth(
let childrenRequireInstantUI = false
let childCreateInstantStack: (() => Error) | null = null
let bestChildConfigDepth = -1
let childFirstModFilePath: string | null = null
for (const parallelRouteKey in parallelRoutes) {
const childSegmentDepth = segmentConsumesURLDepth(segment)
? segmentDepth + 1
......@@ -1250,6 +1278,9 @@ export async function createCombinedPayloadAtDepth(
)
slotResults.set(parallelRouteKey, result)
slots[parallelRouteKey] = result.seedData
if (childFirstModFilePath === null) {
childFirstModFilePath = result.firstModFilePath
}
if (result.requiresInstantUI) {
childrenRequireInstantUI = true
if (
......@@ -1286,10 +1317,15 @@ export async function createCombinedPayloadAtDepth(
configDepth = bestChildConfigDepth
}
// First mod we find in DFS order: this segment's own layout/page if
// any, otherwise the first non-null we got from a child.
const firstModFilePath = localModFilePath ?? childFirstModFilePath
return {
seedData: getCacheNodeSeedDataFromSegment(segmentData, slots),
requiresInstantUI,
createInstantStack,
firstModFilePath,
configDepth,
}
}
......
......@@ -257,6 +257,12 @@ export default async function Page() {
<li>
<DebugLinks href="/suspense-in-root/static/multi-depth-deferred-fallback/inner" />
</li>
<li>
<DebugLinks href="/suspense-in-root/static/test-firstmod/inter/inner" />
</li>
<li>
<DebugLinks href="/suspense-in-root/static/test-multi-unrendered" />
</li>
</ul>
<h2>Disable Validation</h2>
......
// No config. Just a passthrough wrapper. This sits *inside* the
// validation boundary's subtree (the boundary lands at `inner/` because
// the configured layout is one level shallower). If we pick the
// "first mod inside the boundary subtree" correctly, this layout's
// path is what we'd expect to surface — distinct from the configured
// `test-firstmod/layout.tsx` above.
import { ReactNode } from 'react'
export default function InnerLayout({ children }: { children: ReactNode }) {
return <section>{children}</section>
}
// Config lives here (inside __PAGE__ child of inner). The boundary
// lands at `inner` because of depth iteration, and inner/layout.tsx
// is the boundary segment's local mod. If firstModFilePath correctly
// prefers the boundary segment's own layout, the error should point
// at inner/layout.tsx — not this file.
export const unstable_instant = { level: 'experimental-error' }
export default function Page() {
return <p>test-firstmod inner page (should not render)</p>
}
// No config. Just a passthrough wrapper. This sits *inside* the
// validation boundary's subtree (the boundary lands at `inner/` because
// the configured layout is one level shallower). If we pick the
// "first mod inside the boundary subtree" correctly, this layout's
// path is what we'd expect to surface — distinct from the configured
// `test-firstmod/layout.tsx` above.
import { ReactNode } from 'react'
export default function InnerLayout({ children }: { children: ReactNode }) {
return <section>{children}</section>
}
// No config. Hides {children} to trigger the missing-boundary fallback.
// The config lives deeper (inner/leaf/page.tsx), but this layout is
// what prevents it from rendering.
import { ReactNode } from 'react'
export default function Layout({ children }: { children: ReactNode }) {
return (
<main>
<p>test-firstmod root layout — children intentionally not rendered</p>
</main>
)
}
// Required so /test-firstmod is a valid route too. The interesting
// case is /test-firstmod/inner/leaf — see the README... actually, see
// the layout's comment.
export default function Page() {
return <p>test-firstmod root</p>
}
export const unstable_instant = { level: 'experimental-error' }
export default function SidebarPage() {
return <p>sidebar page (should not render)</p>
}
// Drops both {children} and {sidebar}. Both slots have configured
// pages, so both boundaries will be missing — the error should list
// both files.
import { ReactNode } from 'react'
export default function Layout({
children,
sidebar,
}: {
children: ReactNode
sidebar: ReactNode
}) {
return <main>neither slot rendered</main>
}
export const unstable_instant = { level: 'experimental-error' }
export default function Page() {
return <p>children page (should not render)</p>
}
......@@ -583,22 +583,43 @@ describe('instant validation - parallel slot configs', () => {
const browser = await navigateTo(href)
await expect(browser).toDisplayCollapsedRedbox(`
{
"description": "Route "/suspense-in-root/parallel/conditional-breadcrumbs/show-only-breadcrumbs/unblocked": Could not validate \`unstable_instant\` because the target segment was prevented from rendering for an unknown reason.",
"code": "E1246",
"description": "Could not validate instant UI because an expected segment was not rendered.
Unrendered segment:
app/suspense-in-root/parallel/conditional-breadcrumbs/show-only-breadcrumbs/unblocked/page.tsx
Route: /suspense-in-root/parallel/conditional-breadcrumbs/show-only-breadcrumbs/unblocked
This can happen when you conditionally render a parallel route, for instance a login page when a user is logged out.
This can happen when a client component opts out of rendering during SSR.
You can mark this layout as not requiring instant UI with \`export const unstable_instant = false\` if you want to silence this warning.
Learn more: https://nextjs.org/docs/messages/unrendered-instant-segment",
"environmentLabel": "Server",
"label": "Console Error",
"source": "app/suspense-in-root/parallel/conditional-breadcrumbs/show-only-breadcrumbs/unblocked/page.tsx (1:33) @ unstable_instant
> 1 | export const unstable_instant = { level: 'experimental-error' }
| ^",
"stack": [
"unstable_instant app/suspense-in-root/parallel/conditional-breadcrumbs/show-only-breadcrumbs/unblocked/page.tsx (1:33)",
],
"source": null,
"stack": [],
}
`)
} else {
const result = await prerender(href)
expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(`
"Error: Route "/suspense-in-root/parallel/conditional-breadcrumbs/show-only-breadcrumbs/unblocked": Could not validate \`unstable_instant\` because the target segment was prevented from rendering for an unknown reason.
"Error: Could not validate instant UI because an expected segment was not rendered.
Unrendered segment:
app/suspense-in-root/parallel/conditional-breadcrumbs/show-only-breadcrumbs/unblocked/page.tsx
Route: /suspense-in-root/parallel/conditional-breadcrumbs/show-only-breadcrumbs/unblocked
This can happen when you conditionally render a parallel route, for instance a login page when a user is logged out.
This can happen when a client component opts out of rendering during SSR.
You can mark this layout as not requiring instant UI with \`export const unstable_instant = false\` if you want to silence this warning.
Learn more: https://nextjs.org/docs/messages/unrendered-instant-segment
at ignore-listed frames
Build-time instant validation failed for route "/suspense-in-root/parallel/conditional-breadcrumbs/show-only-breadcrumbs/unblocked".
To get a more detailed stack trace and pinpoint the issue, try one of the following:
......
......@@ -3412,15 +3412,24 @@ describe('instant validation', () => {
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"description": "Route "/suspense-in-root/static/multi-depth-deferred-fallback/inner": Could not validate \`unstable_instant\` because the target segment was prevented from rendering for an unknown reason.",
"code": "E1246",
"description": "Could not validate instant UI because an expected segment was not rendered.
Unrendered segment:
app/suspense-in-root/static/multi-depth-deferred-fallback/inner/page.tsx
Route: /suspense-in-root/static/multi-depth-deferred-fallback/inner
This can happen when you conditionally render a parallel route, for instance a login page when a user is logged out.
This can happen when a client component opts out of rendering during SSR.
You can mark this layout as not requiring instant UI with \`export const unstable_instant = false\` if you want to silence this warning.
Learn more: https://nextjs.org/docs/messages/unrendered-instant-segment",
"environmentLabel": "Server",
"label": "Console Error",
"source": "app/suspense-in-root/static/multi-depth-deferred-fallback/inner/page.tsx (7:33) @ unstable_instant
> 7 | export const unstable_instant = { level: 'experimental-error' }
| ^",
"stack": [
"unstable_instant app/suspense-in-root/static/multi-depth-deferred-fallback/inner/page.tsx (7:33)",
],
"source": null,
"stack": [],
}
`)
} else {
......@@ -3429,7 +3438,19 @@ describe('instant validation', () => {
)
expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(`
"Error: Route "/suspense-in-root/static/multi-depth-deferred-fallback/inner": Could not validate \`unstable_instant\` because the target segment was prevented from rendering for an unknown reason.
"Error: Could not validate instant UI because an expected segment was not rendered.
Unrendered segment:
app/suspense-in-root/static/multi-depth-deferred-fallback/inner/page.tsx
Route: /suspense-in-root/static/multi-depth-deferred-fallback/inner
This can happen when you conditionally render a parallel route, for instance a login page when a user is logged out.
This can happen when a client component opts out of rendering during SSR.
You can mark this layout as not requiring instant UI with \`export const unstable_instant = false\` if you want to silence this warning.
Learn more: https://nextjs.org/docs/messages/unrendered-instant-segment
at ignore-listed frames
Build-time instant validation failed for route "/suspense-in-root/static/multi-depth-deferred-fallback/inner".
To get a more detailed stack trace and pinpoint the issue, try one of the following:
......@@ -3442,6 +3463,134 @@ describe('instant validation', () => {
})
})
describe('unrendered segment file reporting', () => {
it('reports the shallowest unrendered file, not the configured file', async () => {
// Config is on inter/inner/page.tsx. The shallowest boundary
// iteration lands at test-firstmod, and inter/layout.tsx is the
// first child mod that didn't render — not the configured page,
// and not test-firstmod/layout.tsx (which DID render but dropped
// its children).
if (isNextDev) {
const browser = await navigateTo(
'/suspense-in-root/static/test-firstmod/inter/inner'
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1246",
"description": "Could not validate instant UI because an expected segment was not rendered.
Unrendered segment:
app/suspense-in-root/static/test-firstmod/inter/layout.tsx
Route: /suspense-in-root/static/test-firstmod/inter/inner
This can happen when you conditionally render a parallel route, for instance a login page when a user is logged out.
This can happen when a client component opts out of rendering during SSR.
You can mark this layout as not requiring instant UI with \`export const unstable_instant = false\` if you want to silence this warning.
Learn more: https://nextjs.org/docs/messages/unrendered-instant-segment",
"environmentLabel": "Server",
"label": "Console Error",
"source": null,
"stack": [],
}
`)
} else {
const result = await prerender(
'/suspense-in-root/static/test-firstmod/inter/inner'
)
expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(`
"Error: Could not validate instant UI because an expected segment was not rendered.
Unrendered segment:
app/suspense-in-root/static/test-firstmod/inter/layout.tsx
Route: /suspense-in-root/static/test-firstmod/inter/inner
This can happen when you conditionally render a parallel route, for instance a login page when a user is logged out.
This can happen when a client component opts out of rendering during SSR.
You can mark this layout as not requiring instant UI with \`export const unstable_instant = false\` if you want to silence this warning.
Learn more: https://nextjs.org/docs/messages/unrendered-instant-segment
at ignore-listed frames
Build-time instant validation failed for route "/suspense-in-root/static/test-firstmod/inter/inner".
To get a more detailed stack trace and pinpoint the issue, try one of the following:
- Start the app in development mode by running \`next dev\`, then open "/suspense-in-root/static/test-firstmod/inter/inner" in your browser to investigate the error.
- Rerun the production build with \`next build --debug-prerender\` to generate better stack traces.
Stopping prerender due to instant validation errors."
`)
expect(result.exitCode).toBe(1)
}
})
it('reports the boundary segment layout when multiple slots are dropped', async () => {
// Layout drops both {children} and {sidebar}. Both have
// configured pages, but only one boundary id is created (at
// the segment level, covering all slots). The reported file is
// the boundary segment's own layout — the nearest mod to the
// boundary placement.
if (isNextDev) {
const browser = await navigateTo(
'/suspense-in-root/static/test-multi-unrendered'
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1246",
"description": "Could not validate instant UI because an expected segment was not rendered.
Unrendered segments:
app/suspense-in-root/static/test-multi-unrendered/@sidebar/page.tsx
app/suspense-in-root/static/test-multi-unrendered/page.tsx
Route: /suspense-in-root/static/test-multi-unrendered
This can happen when you conditionally render a parallel route, for instance a login page when a user is logged out.
This can happen when a client component opts out of rendering during SSR.
You can mark this layout as not requiring instant UI with \`export const unstable_instant = false\` if you want to silence this warning.
Learn more: https://nextjs.org/docs/messages/unrendered-instant-segment",
"environmentLabel": "Server",
"label": "Console Error",
"source": null,
"stack": [],
}
`)
} else {
const result = await prerender(
'/suspense-in-root/static/test-multi-unrendered'
)
expect(extractBuildValidationError(result.cliOutput))
.toMatchInlineSnapshot(`
"Error: Could not validate instant UI because an expected segment was not rendered.
Unrendered segments:
app/suspense-in-root/static/test-multi-unrendered/@sidebar/page.tsx
app/suspense-in-root/static/test-multi-unrendered/page.tsx
Route: /suspense-in-root/static/test-multi-unrendered
This can happen when you conditionally render a parallel route, for instance a login page when a user is logged out.
This can happen when a client component opts out of rendering during SSR.
You can mark this layout as not requiring instant UI with \`export const unstable_instant = false\` if you want to silence this warning.
Learn more: https://nextjs.org/docs/messages/unrendered-instant-segment
at ignore-listed frames
Build-time instant validation failed for route "/suspense-in-root/static/test-multi-unrendered".
To get a more detailed stack trace and pinpoint the issue, try one of the following:
- Start the app in development mode by running \`next dev\`, then open "/suspense-in-root/static/test-multi-unrendered" in your browser to investigate the error.
- Rerun the production build with \`next build --debug-prerender\` to generate better stack traces.
Stopping prerender due to instant validation errors."
`)
expect(result.exitCode).toBe(1)
}
})
})
describe('disabling validation', () => {
it('in a layout', async () => {
if (isNextDev) {
......
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