Files
next.js/test/development/app-dir/cache-components-dev-fallback-validation/cache-components-dev-fallback-validation.test.ts
Aurora ScharffandGitHub 18d2e2da5f Insights: use a single Learn more link in console errors (#95967)
## Summary

The instant / blocking-prerender insight console errors printed a docs
URL under each fix option (two or three anchors per message). This
collapses them to a single `Learn more:` link at the end of each
message, while keeping the `[stream]`/`[cache]`/`[block]` fix-option
labels. It restores the single-link format these builders originally
shipped with.

**Before:**

```
Ways to fix this:
  - [stream] Provide a placeholder with `<Suspense fallback={...}>` around the data access
    https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense
  - [block] Set `export const instant = false` to allow a blocking route
    https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
```

**After:**

```
Ways to fix this:
  - [stream] Provide a placeholder with `<Suspense fallback={...}>` around the data access
  - [block] Set `export const instant = false` to allow a blocking route

Learn more: https://nextjs.org/docs/messages/blocking-prerender-runtime
```

Covers all 16 insight-kind errors, across `blocking-route-messages.ts`,
`sync-io-messages.ts`, `dynamic-rendering-utils.ts`, and
`instant-messages.ts`.

Because the dev overlay classified these errors by the `#`-anchored docs
URL, `getBlockingRouteErrorDetails` is updated to match the anchor-less
`Learn more:` URL. Console-message snapshots and the guidance-data
extraction test are updated to the new format. The dev-overlay fix-card
data (`instant-guidance-data.ts`) keeps its per-card links, since those
are the overlay UI rather than the console message.

## Verification

- `pnpm --filter=next types`
- Snapshots regenerated with `jest -u` for the affected suites

<!-- NEXT_JS_LLM -->
2026-07-21 12:53:17 +02:00

200 lines
7.0 KiB
TypeScript

import { nextTestSetup } from 'e2e-utils'
import { waitForNoRedbox } from 'next-test-utils'
describe('Cache Components Fallback Validation', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should not warn about missing Suspense when accessing params if static params are completely known at build time', async () => {
// when the params are complete we don't expect to see any errors await params regarless of where there
// are Suspense boundaries.
const browser = await next.browser(
'/complete/prerendered/wrapped/prerendered'
)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/complete/prerendered/wrapped/novel`)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/complete/novel/wrapped/novel`)
await waitForNoRedbox(browser)
await browser.loadPage(
`${next.url}/complete/prerendered/unwrapped/prerendered`
)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/complete/prerendered/unwrapped/novel`)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/complete/novel/unwrapped/novel`)
await waitForNoRedbox(browser)
})
it('should warn about missing Suspense when accessing params if static params are partially known at build time', async () => {
// when the params are partially complete we don't expect to see any errors awaiting the params that are known
// but do expect errors awaiting the params that are not known if not inside a Suspense boundary.
const browser = await next.browser(
'/partial/prerendered/wrapped/prerendered'
)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/partial/prerendered/wrapped/novel`)
await waitForNoRedbox(browser)
await browser.loadPage(`${next.url}/partial/novel/wrapped/novel`)
await waitForNoRedbox(browser)
await browser.loadPage(
`${next.url}/partial/prerendered/unwrapped/prerendered`
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1427",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
> 6 | Top: {(await props.params).top}, Bottom: {(await props.params).bottom}
| ^",
"stack": [
"Page app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26)",
],
}
`)
await browser.loadPage(`${next.url}/partial/prerendered/unwrapped/novel`)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1427",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26) @ Page
> 6 | Top: {(await props.params).top}, Bottom: {(await props.params).bottom}
| ^",
"stack": [
"Page app/partial/[top]/unwrapped/[bottom]/page.tsx (6:26)",
],
}
`)
await browser.loadPage(`${next.url}/partial/novel/unwrapped/novel`)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1427",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/partial/[top]/unwrapped/layout.tsx (8:3) @ Layout
> 8 | await params
| ^",
"stack": [
"Layout app/partial/[top]/unwrapped/layout.tsx (8:3)",
],
}
`)
})
it('should warn about missing Suspense when accessing params if static params are entirely missing at build time', async () => {
// when the params are partially complete we don't expect to see any errors awaiting the params that are known
// but do expect errors awaiting the params that are not known if not inside a Suspense boundary.
const browser = await next.browser('/none/prerendered/wrapped/prerendered')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1427",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
> 10 | await params
| ^",
"stack": [
"Layout app/none/[top]/wrapped/layout.tsx (10:3)",
],
}
`)
await browser.loadPage(`${next.url}/none/prerendered/wrapped/novel`)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1427",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
> 10 | await params
| ^",
"stack": [
"Layout app/none/[top]/wrapped/layout.tsx (10:3)",
],
}
`)
await browser.loadPage(`${next.url}/none/novel/wrapped/novel`)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1427",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/wrapped/layout.tsx (10:3) @ Layout
> 10 | await params
| ^",
"stack": [
"Layout app/none/[top]/wrapped/layout.tsx (10:3)",
],
}
`)
await browser.loadPage(`${next.url}/none/prerendered/unwrapped/prerendered`)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1427",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
> 8 | await params
| ^",
"stack": [
"Layout app/none/[top]/unwrapped/layout.tsx (8:3)",
],
}
`)
await browser.loadPage(`${next.url}/none/prerendered/unwrapped/novel`)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1427",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
> 8 | await params
| ^",
"stack": [
"Layout app/none/[top]/unwrapped/layout.tsx (8:3)",
],
}
`)
await browser.loadPage(`${next.url}/none/novel/unwrapped/novel`)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1427",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
"source": "app/none/[top]/unwrapped/layout.tsx (8:3) @ Layout
> 8 | await params
| ^",
"stack": [
"Layout app/none/[top]/unwrapped/layout.tsx (8:3)",
],
}
`)
})
})