Unverified Commit f965c004 authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

Insights: drop irrelevant fix cards from instant errors (#94926)

### Why?

Two Insight fix cards were misleading:

1. **`generateStaticParams` showed up on every runtime/client-hook
insight.** One error covers `cookies()` / `headers()` / `params` /
`searchParams`. GSP only applies to `params`; for the others it's noise.
Even for `params` it nudges devs to make the route static instead of
fixing the immediate error.
2. **`"use cache"` showed up on `connection()` triggers.** Caching
`connection()` is contradictory.

Both manifest on initial load and in-navigation (the fix-card sets are
shared).

### What?

1. **Drop the GSP card** from runtime + client-hook sets. Affects
[01-cookies-body](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/01-cookies-body),
[03-params-body](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/03-params-body),
[90-client-use-params](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/90-client-use-params),
[41-subnav-cookies](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/41-subnav-cookies),
[42-subnav-fetch](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/42-subnav-fetch).
2. **Filter `"use cache"`** when the cause is `connection()`. Affects
[05-connection-body](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/05-connection-body),
[08-connection-body-dynamic](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/08-connection-body-dynamic),
[31-connection-in-metadata](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/31-connection-in-metadata),
[33-connection-in-viewport](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/33-connection-in-viewport).
[06-uncached-fetch-body](https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/06-uncached-fetch-body)
keeps the Cache card.

### How?

- `getCards()` filters the cache card when `cause === 'connection'`.
- New `deriveCauseFromCodeFrame()` helper detects `connection(` on the
highlighted code-frame line.
- `ParamClientHookDynamicError` collapsed into `ClientHookDynamicError`.
- CLI/build messages: dropped the GSP bullet; added `(does not apply to
\`connection()\`)` on the cache bullet.
- Docs: removed `For known params, prerender` sections; added a
connection caveat on dynamic/metadata-dynamic/viewport-dynamic pages.

<!-- NEXT_JS_LLM_PR -->
parent 70407f12
......@@ -191,9 +191,7 @@ impl Issue for MiddlewareMissingExportIssue {
To fix it:\n\
- Ensure this file has either a default or \"{}\" function export.\n\n\
Learn more: https://nextjs.org/docs/messages/middleware-to-proxy",
type_description,
migration_bullet,
self.function_name
type_description, migration_bullet, self.function_name
);
Ok(Some(StyledString::Text(description_text.into())))
......
......@@ -575,6 +575,8 @@ impl Issue for StaticMetadataFileSizeIssue {
}
fn documentation_link(&self) -> RcStr {
rcstr!("https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image#image-files-jpg-png-gif")
rcstr!(
"https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image#image-files-jpg-png-gif"
)
}
}
......@@ -141,8 +141,10 @@ impl Fold for PageConfig {
impl PageConfig {
fn handle_error(&mut self, details: &str, span: Span) {
if self.is_page_file {
let message = format!("Invalid page config export found. {details} \
See: https://nextjs.org/docs/messages/invalid-page-config");
let message = format!(
"Invalid page config export found. {details} \
See: https://nextjs.org/docs/messages/invalid-page-config"
);
HANDLER.with(|handler| handler.struct_span_err(span, &message).emit());
}
}
......
......@@ -5,7 +5,7 @@ kind: insight
During [prerendering](/docs/app/glossary#prerendering), a Client Component called a navigation hook ([`usePathname`](/docs/app/api-reference/functions/use-pathname), [`useParams`](/docs/app/api-reference/functions/use-params), [`useSearchParams`](/docs/app/api-reference/functions/use-search-params#prerendering), [`useSelectedLayoutSegment`](/docs/app/api-reference/functions/use-selected-layout-segment), or [`useSelectedLayoutSegments`](/docs/app/api-reference/functions/use-selected-layout-segments)) outside of a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary. With [Cache Components](/docs/app/api-reference/config/next-config-js/cacheComponents) enabled, Next.js prerenders as much of a route as possible before a request arrives. These hooks read URL data that is not available during prerendering, so the component needs a fallback to include in the [static shell](/docs/app/glossary#static-shell).
`useSearchParams` triggers this error on any prerendered route because search params come from the request URL. The other four hooks trigger it when the route has dynamic params not covered by [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params).
`useSearchParams` triggers this error on any prerendered route because search params come from the request URL. The other four hooks trigger it when the route has dynamic params and is rendered per-request.
Server-side request-bound reads ([`cookies()`](/docs/app/api-reference/functions/cookies), [`headers()`](/docs/app/api-reference/functions/headers)) have different fixes. See [Next.js encountered runtime data during prerendering](/docs/messages/blocking-prerender-runtime). For unstable values like [`Math.random()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) in Client Components, see [Next.js encountered the unstable value Math.random() in a Client Component](/docs/messages/blocking-prerender-random-client).
......@@ -22,15 +22,6 @@ Server-side request-bound reads ([`cookies()`](/docs/app/api-reference/functions
prerender a fallback while the runtime value loads.
</FixOption>
<FixOption
group="cache"
href="#for-known-params-prerender"
title="For known params, prerender"
>
Tell Next.js the full set of valid params ahead of time. Each one becomes a
prerendered route. Does not help useSearchParams.
</FixOption>
<FixOption
group="block"
href="#allow-blocking-route"
......@@ -191,36 +182,6 @@ The user sees the fallback on the first paint of the suspended region, then it s
- The static shell does not include the active state. The fallback paints first, then the indicator hydrates and the active style appears. For active-link patterns where the flash is visible, add an [inline script that runs before paint](/docs/app/guides/preventing-flash-before-hydration) to set the active attribute from `location.pathname` so the correct link is styled on the first paint.
- [`usePathname`](/docs/app/api-reference/functions/use-pathname#avoid-hydration-mismatch-with-rewrites) reads the source path on the server when the request was rewritten in `next.config` or middleware, while the browser sees the rewritten path. The active state on a rewritten route resolves to the wrong link on the server and corrects itself on hydration. If your app uses rewrites, defer the read until after mount as the [docs recommend](/docs/app/api-reference/functions/use-pathname#avoid-hydration-mismatch-with-rewrites).
## For known params, prerender
Choose this fix when you know the valid param values at build time. Adding [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) tells Next.js to prerender each one. On those prerendered routes, [`useParams`](/docs/app/api-reference/functions/use-params) resolves to a build-time constant, and the [`Suspense` boundary around `usePathname` is optional](/docs/app/api-reference/functions/use-pathname). This fix does not apply to [`useSearchParams`](/docs/app/api-reference/functions/use-search-params), since search params come from the request URL's query string and are not part of the segment params.
### Patterns
#### Export generateStaticParams
Export [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) from the page or layout that defines the dynamic segment. Return an array of param objects whose keys match the segment's `[param]` names.
```jsx filename="app/blog/[slug]/page.js"
export function generateStaticParams() {
return [{ slug: 'hello-world' }, { slug: 'release-notes' }]
}
```
Learn more: [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params).
### Trade-off
The list of params is decided at build time. See [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) for rebuild and cache-invalidation patterns when the list changes.
### Gotchas
- [`useSearchParams`](/docs/app/api-reference/functions/use-search-params) is never affected by [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params). Search params come from the request URL's query string. If a route reads `useSearchParams`, you still need a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary around that read or [Allow blocking route](#allow-blocking-route) on the segment.
- A request for a param value not in the returned list falls through to runtime rendering. The same client hook will suspend on that request unless the segment is wrapped in `<Suspense>` or marked with [Allow blocking route](#allow-blocking-route).
- The generated paths must cover every dynamic segment in the route. If any segment is missing, the route falls back to runtime rendering for that param.
- [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) runs at build time, so it cannot depend on per-request values.
- The [`dynamicParams`](/docs/app/api-reference/file-conventions/route-segment-config/dynamicParams) config isn't available in this model. If you're migrating an existing page, use [`<Suspense>`](https://react.dev/reference/react/Suspense), [`notFound()`](/docs/app/api-reference/functions/not-found), or [Allow blocking route](#allow-blocking-route) instead.
## Allow blocking route
Choose this fix when the route renders per-request and there's no useful static shell. Setting [`instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` exempts the segment from instant-navigation validation. The page renders on every request and the navigation blocks until that render completes.
......@@ -260,7 +221,7 @@ Use either pattern when:
- The route needs request-time data high in the tree to decide what to render, so there is no meaningful [static shell](/docs/app/glossary#static-shell) worth showing first.
- You're migrating a route incrementally and want to defer the lifetime decision without changing how the page renders today.
For a client-hook error this is rarely the right answer. The hook reads a small piece of URL data, and a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary around that read keeps the rest of the route prerendered. Choose [Wrap in or move into Suspense](#wrap-in-or-move-into-suspense) or [For known params, prerender](#for-known-params-prerender) when either is feasible.
For a client-hook error this is rarely the right answer. The hook reads a small piece of URL data, and a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary around that read keeps the rest of the route prerendered. Choose [Wrap in or move into Suspense](#wrap-in-or-move-into-suspense) when feasible.
### Trade-off
......
......@@ -44,6 +44,8 @@ This error can also appear during a client-side navigation when the data access
Choose this fix when the data does not need to be regenerated on every request. Move the call into a function and add the [`use cache`](/docs/app/api-reference/directives/use-cache) directive as the first statement of the function body. The function still runs the underlying query, but Next.js caches the result for the configured lifetime and the surrounding route becomes prerenderable.
This fix does not apply to [`connection()`](/docs/app/api-reference/functions/connection). The whole point of `connection()` is to opt into per-request rendering for the wrapped subtree, so caching it would defeat the purpose. Use [Wrap in or move into Suspense](#wrap-in-or-move-into-suspense) instead.
### Patterns
#### Cache the data-access function
......
......@@ -33,6 +33,8 @@ For errors in the page body rather than metadata, see [Next.js encountered uncac
Choose this fix when the metadata comes from an external source (CMS, database) but doesn't need to change on every request. Add the [`use cache`](/docs/app/api-reference/directives/use-cache) directive as the first statement inside [`generateMetadata()`](/docs/app/api-reference/functions/generate-metadata). Next.js caches the returned metadata object and includes it in the prerender.
This fix does not apply to [`connection()`](/docs/app/api-reference/functions/connection). The point of `connection()` is to opt into per-request rendering, so caching it would defeat the purpose. Use [Mark the route as dynamic](#mark-the-route-as-dynamic) instead.
### Patterns
#### Add `use cache` to `generateMetadata`
......
......@@ -22,15 +22,6 @@ This error can also appear during a client-side navigation when the data access
or push the read down to the leaf that needs it.
</FixOption>
<FixOption
group="cache"
href="#for-known-params-prerender"
title="For known params, prerender"
>
Tell Next.js the full set of valid params ahead of time. Each one becomes a
prerendered route.
</FixOption>
<FixOption
group="block"
href="#allow-blocking-route"
......@@ -180,58 +171,6 @@ A useful rule: **push the boundary as low as possible** while keeping the fallba
- The function returned by [`cookies()`](/docs/app/api-reference/functions/cookies) and [`headers()`](/docs/app/api-reference/functions/headers) is async. Make sure the component reading them is async too, and `await` the call.
- The `params` and `searchParams` props are also async promises. Treat them like any other awaited value when deciding where the boundary goes.
## For known params, prerender
Choose this fix when the route has a closed set of valid params and you know them at build time. Adding [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) tells Next.js to prerender each one, so the per-request `params` value becomes a build-time constant for those entries.
### Patterns
#### Return a fixed list
Return the full list of params from the export. Use this for routes whose param space is small and known.
```jsx filename="app/dashboard/[team]/page.js"
export function generateStaticParams() {
return [{ team: 'marketing' }, { team: 'sales' }, { team: 'ops' }]
}
export default async function Page({ params }) {
const { team } = await params
return <TeamDashboard team={team} />
}
```
Learn more: [`generateStaticParams` basics](/docs/app/api-reference/functions/generate-static-params).
#### Fetch the list at build time
When the param values come from a content source, fetch them inside `generateStaticParams`. Next.js calls the function once at build time.
```jsx filename="app/dashboard/[team]/page.js"
export async function generateStaticParams() {
const teams = await db.teams.findMany({ select: { slug: true } })
return teams.map((team) => ({ team: team.slug }))
}
export default async function Page({ params }) {
const { team } = await params
const dashboard = await getDashboard(team)
return <TeamDashboard dashboard={dashboard} />
}
```
Learn more: [ISR with Cache Components](/docs/app/guides/incremental-static-regeneration-cache-components).
### Trade-off
The list of params is decided at build time. See [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) for rebuild and cache-invalidation patterns when the list changes. A request for a param not in the returned list falls through to runtime rendering, so the runtime data read still needs a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary or [Allow blocking route](#allow-blocking-route).
### Gotchas
- The [`generateStaticParams`](/docs/app/api-reference/functions/generate-static-params) function only handles `params`. It does not solve [`cookies()`](/docs/app/api-reference/functions/cookies), [`headers()`](/docs/app/api-reference/functions/headers), or [`searchParams`](/docs/app/api-reference/file-conventions/page#searchparams-optional). If the page also reads any of those, you still need a [`<Suspense>`](https://react.dev/reference/react/Suspense) boundary.
- The function runs at build time, so it can't depend on per-request values. Reading [`cookies()`](/docs/app/api-reference/functions/cookies) or [`headers()`](/docs/app/api-reference/functions/headers) inside it throws.
- The [`dynamicParams`](/docs/app/api-reference/file-conventions/route-segment-config/dynamicParams) config isn't available in this model. If you're migrating an existing page, use [`<Suspense>`](https://react.dev/reference/react/Suspense), [`notFound()`](/docs/app/api-reference/functions/not-found), or [Allow blocking route](#allow-blocking-route) instead.
## Allow blocking route
Choose this fix when the route renders per-request and there's no useful static shell. Setting [`instant`](/docs/app/api-reference/file-conventions/route-segment-config/instant) to `false` exempts the segment from instant-navigation validation. The page renders on every request and the navigation blocks until that render completes.
......@@ -272,7 +211,7 @@ Use either pattern when:
- The route needs request-time data high in the tree to decide what to render (for example auth, tenant, or other gating in a layout), so there is no meaningful [static shell](/docs/app/glossary#static-shell) worth showing first.
- You're migrating a route incrementally and want to defer the lifetime decision without changing how the page renders today.
Don't use this to dismiss the error. Choose [Wrap in or move into Suspense](#wrap-in-or-move-into-suspense) or [For known params, prerender](#for-known-params-prerender) when either is feasible.
Don't use this to dismiss the error. Choose [Wrap in or move into Suspense](#wrap-in-or-move-into-suspense) when feasible.
### Trade-off
......
......@@ -33,6 +33,8 @@ Request-bound reads ([`cookies()`](/docs/app/api-reference/functions/cookies), [
Choose this fix when the viewport values come from an external source (database, CMS) but don't need to change on every request. Add the [`use cache`](/docs/app/api-reference/directives/use-cache) directive as the first statement inside [`generateViewport()`](/docs/app/api-reference/functions/generate-viewport). Next.js caches the returned viewport object and includes it in the prerender.
This fix does not apply to [`connection()`](/docs/app/api-reference/functions/connection). The point of `connection()` is to opt into per-request rendering, so caching it would defeat the purpose. Use [Allow blocking route](#allow-blocking-route) instead.
### Patterns
#### Add `use cache` to `generateViewport`
......
This diff is collapsed.
import {
createRuntimeBodyError,
createDynamicBodyError,
createRuntimeBodyErrorInNavigation,
createDynamicBodyErrorInNavigation,
createRuntimeMetadataError,
createDynamicMetadataError,
createRuntimeViewportError,
createDynamicViewportError,
} from '../../../../server/app-render/blocking-route-messages'
import {
FIX_CARD_GROUPS,
SYNC_IO_DOCS,
SYNC_IO_CLIENT_DOCS,
getCards,
type FixCardGroup,
type GuidanceKind,
type GuidanceVariant,
} from './instant-guidance-data'
function tagsFromMessage(message: string): string[] {
return Array.from(message.matchAll(/^\s*-\s*\[([a-z]+)\]/gm)).map((m) => m[1])
}
function groupsFromCards(
kind: GuidanceKind,
variant: GuidanceVariant
): string[] {
return getCards(kind, variant).map((card) => card.group)
}
describe('instant-guidance-data card ordering', () => {
it.each([
[
'blocking-route runtime',
createRuntimeBodyError('/x').message,
'blocking-route',
'runtime',
],
[
'blocking-route dynamic',
createDynamicBodyError('/x').message,
'blocking-route',
'dynamic',
],
[
'blocking-route runtime in navigation',
createRuntimeBodyErrorInNavigation('/x').message,
'blocking-route',
'runtime',
],
[
'blocking-route dynamic in navigation',
createDynamicBodyErrorInNavigation('/x').message,
'blocking-route',
'dynamic',
],
[
'metadata runtime',
createRuntimeMetadataError('/x').message,
'metadata',
'runtime',
],
[
'metadata dynamic',
createDynamicMetadataError('/x').message,
'metadata',
'dynamic',
],
[
'viewport runtime',
createRuntimeViewportError('/x').message,
'viewport',
'runtime',
],
[
'viewport dynamic',
createDynamicViewportError('/x').message,
'viewport',
'dynamic',
],
] as const)(
'console tags and overlay card groups agree for %s',
(_name, message, kind, variant) => {
expect(tagsFromMessage(message)).toEqual(groupsFromCards(kind, variant))
}
)
})
function linksFromMessage(message: string): string[] {
return Array.from(message.matchAll(/^\s+(https:\/\/\S+)/gm)).map((m) => m[1])
}
describe('instant-guidance-data card links', () => {
it.each([
[
'blocking-route runtime',
createRuntimeBodyError('/x').message,
'blocking-route',
'runtime',
],
[
'blocking-route dynamic',
createDynamicBodyError('/x').message,
'blocking-route',
'dynamic',
],
[
'metadata runtime',
createRuntimeMetadataError('/x').message,
'metadata',
'runtime',
],
[
'metadata dynamic',
createDynamicMetadataError('/x').message,
'metadata',
'dynamic',
],
[
'viewport runtime',
createRuntimeViewportError('/x').message,
'viewport',
'runtime',
],
[
'viewport dynamic',
createDynamicViewportError('/x').message,
'viewport',
'dynamic',
],
] as const)(
'console URLs and overlay card links agree for %s',
(_name, message, kind, variant) => {
const cardLinks = getCards(kind, variant).map((card) => card.link)
expect(linksFromMessage(message)).toEqual(cardLinks)
}
)
it('every card.link ends with #card.id', () => {
const variants: Array<[GuidanceKind, GuidanceVariant]> = [
['blocking-route', 'runtime'],
['blocking-route', 'dynamic'],
['client-hook', 'runtime'],
['metadata', 'runtime'],
['metadata', 'dynamic'],
['viewport', 'runtime'],
['viewport', 'dynamic'],
['unrendered-segment', 'runtime'],
]
for (const [kind, variant] of variants) {
for (const card of getCards(kind, variant)) {
if (card.link === null) continue
expect(card.link).toMatch(new RegExp(`#${card.id}$`))
}
}
})
})
describe('instant-guidance-data card invariants', () => {
function allCards() {
const cards = []
const variants: Array<[GuidanceKind, GuidanceVariant, string?]> = [
['blocking-route', 'runtime'],
['blocking-route', 'dynamic'],
['blocking-route', 'dynamic', 'connection'],
['client-hook', 'runtime'],
['metadata', 'runtime'],
['metadata', 'dynamic'],
['metadata', 'dynamic', 'connection'],
['viewport', 'runtime'],
['viewport', 'dynamic'],
['viewport', 'dynamic', 'connection'],
['unrendered-segment', 'runtime'],
]
for (const [kind, variant, cause] of variants) {
cards.push(...getCards(kind, variant, cause))
}
for (const cause of Object.keys(SYNC_IO_DOCS)) {
cards.push(...getCards('sync-io', 'runtime', cause))
}
for (const cause of Object.keys(SYNC_IO_CLIENT_DOCS)) {
cards.push(...getCards('sync-io-client', 'runtime', cause))
}
return cards
}
it('every card group is registered in FIX_CARD_GROUPS', () => {
for (const card of allCards()) {
expect(FIX_CARD_GROUPS).toHaveProperty(card.group)
}
})
it('every card has a non-empty title and at least one snippet', () => {
for (const card of allCards()) {
expect(card.title).not.toBe('')
expect(card.snippets.length).toBeGreaterThan(0)
}
})
it('every link is either null or a docs URL', () => {
for (const card of allCards()) {
if (card.link === null) continue
expect(card.link).toMatch(/^https:\/\/nextjs\.org\/docs\/messages\//)
}
})
})
describe('instant-guidance-data dispatcher', () => {
it('filterCacheForConnection removes the cache card for connection() cause', () => {
const withoutCause = getCards('blocking-route', 'dynamic')
const withConnection = getCards('blocking-route', 'dynamic', 'connection')
expect(withoutCause.map((c) => c.group)).toContain('cache')
expect(withConnection.map((c) => c.group)).not.toContain('cache')
})
it('returns non-empty cards for every documented sync-io cause', () => {
for (const cause of Object.keys(SYNC_IO_DOCS)) {
expect(getCards('sync-io', 'runtime', cause).length).toBeGreaterThan(0)
}
for (const cause of Object.keys(SYNC_IO_CLIENT_DOCS)) {
expect(
getCards('sync-io-client', 'runtime', cause).length
).toBeGreaterThan(0)
}
})
it('every group in FIX_CARD_GROUPS is used by at least one card', () => {
const used = new Set<FixCardGroup>()
const variants: Array<[GuidanceKind, GuidanceVariant]> = [
['blocking-route', 'runtime'],
['blocking-route', 'dynamic'],
['client-hook', 'runtime'],
['metadata', 'runtime'],
['metadata', 'dynamic'],
['viewport', 'runtime'],
['viewport', 'dynamic'],
['unrendered-segment', 'runtime'],
]
for (const [kind, variant] of variants) {
for (const card of getCards(kind, variant)) used.add(card.group)
}
for (const cause of Object.keys(SYNC_IO_DOCS)) {
for (const card of getCards('sync-io', 'runtime', cause))
used.add(card.group)
}
for (const cause of Object.keys(SYNC_IO_CLIENT_DOCS)) {
for (const card of getCards('sync-io-client', 'runtime', cause))
used.add(card.group)
}
for (const group of Object.keys(FIX_CARD_GROUPS) as FixCardGroup[]) {
expect(used).toContain(group)
}
})
})
......@@ -48,7 +48,6 @@ export type FixCard = {
/** Docs URL the card links to, or `null` for no link. */
link: string | null
snippets: Snippet[]
/** Whether to render the "Copy AI prompt" button on this card. */
copyable?: boolean
}
......@@ -66,8 +65,6 @@ export type Snippet = {
parts?: SnippetPart[]
}
// ── Blocking-route cards ──────────────────────────
const runtimeCards: FixCard[] = [
{
id: 'wrap-in-or-move-into-suspense',
......@@ -81,31 +78,6 @@ const runtimeCards: FixCard[] = [
],
copyable: true,
},
{
id: 'for-known-params-prerender',
title: 'For known params, prerender',
group: 'cache',
link: 'https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender',
snippets: [
{
text: 'function generateStaticParams() {',
parts: [
{ text: 'function ' },
{ text: 'generateStaticParams', highlight: true },
{ text: '() {' },
],
},
{
text: ' return [{ slug: "…" }]',
parts: [
{ text: ' return ' },
{ text: '[{ slug: "…" }]', highlight: true },
],
},
{ text: '}' },
],
copyable: true,
},
{
id: 'allow-blocking-route',
title: 'Allow blocking route',
......@@ -144,64 +116,9 @@ const clientHookBlockCard: FixCard = {
copyable: true,
}
const clientHookGspCard: FixCard = {
id: 'for-known-params-prerender',
title: 'For known params, prerender',
group: 'cache',
link: 'https://nextjs.org/docs/messages/blocking-prerender-client-hook#for-known-params-prerender',
snippets: [
{
text: 'function generateStaticParams() {',
parts: [
{ text: 'function ' },
{ text: 'generateStaticParams', highlight: true },
{ text: '() {' },
],
},
{
text: ' return [{ slug: "…" }]',
parts: [
{ text: ' return ' },
{ text: '[{ slug: "…" }]', highlight: true },
],
},
{ text: '}' },
],
copyable: true,
}
/** useSearchParams: Stream + Block (GSP doesn't apply — search params come from request). */
const clientHookCardsSearchParams: FixCard[] = [
clientHookSuspenseCard,
clientHookBlockCard,
]
/** useParams: Stream + GSP + Block. */
const clientHookCardsWithGsp: FixCard[] = [
clientHookSuspenseCard,
clientHookGspCard,
clientHookBlockCard,
]
/** usePathname, useSelectedLayoutSegment(s): Stream + Block. */
const clientHookCardsNoGsp: FixCard[] = [
clientHookSuspenseCard,
clientHookBlockCard,
]
const clientHookCards: FixCard[] = [clientHookSuspenseCard, clientHookBlockCard]
const dynamicCards: FixCard[] = [
{
id: 'cache-the-component-or-data',
title: 'Cache the component or data',
group: 'cache',
link: 'https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data',
snippets: [
{ text: 'async function Posts() {' },
{ text: ' "use cache"', highlight: true },
{ text: ' return <List items={…} />' },
],
copyable: true,
},
{
id: 'wrap-in-or-move-into-suspense',
title: 'Wrap in or move into Suspense',
......@@ -214,6 +131,18 @@ const dynamicCards: FixCard[] = [
],
copyable: true,
},
{
id: 'cache-the-component-or-data',
title: 'Cache the component or data',
group: 'cache',
link: 'https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data',
snippets: [
{ text: 'async function Posts() {' },
{ text: ' "use cache"', highlight: true },
{ text: ' return <List items={…} />' },
],
copyable: true,
},
{
id: 'allow-blocking-route',
title: 'Allow blocking route',
......@@ -227,8 +156,6 @@ const dynamicCards: FixCard[] = [
},
]
// ── Unrendered-segment cards ──────────────────────
const unrenderedSegmentCards: FixCard[] = [
{
id: 'render-the-dropped-segment',
......@@ -270,8 +197,6 @@ const unrenderedSegmentCards: FixCard[] = [
},
]
// ── Metadata cards ────────────────────────────────
const metadataRuntimeCards: FixCard[] = [
{
id: 'use-static-metadata',
......@@ -286,7 +211,7 @@ const metadataRuntimeCards: FixCard[] = [
copyable: true,
},
{
id: 'render-page-at-request-time',
id: 'mark-the-route-as-dynamic',
title: 'Mark the route as dynamic',
group: 'dynamic',
link: 'https://nextjs.org/docs/messages/blocking-prerender-metadata-runtime#mark-the-route-as-dynamic',
......@@ -312,7 +237,7 @@ const metadataDynamicCards: FixCard[] = [
copyable: true,
},
{
id: 'render-page-at-request-time',
id: 'mark-the-route-as-dynamic',
title: 'Mark the route as dynamic',
group: 'dynamic',
link: 'https://nextjs.org/docs/messages/blocking-prerender-metadata-dynamic#mark-the-route-as-dynamic',
......@@ -324,8 +249,6 @@ const metadataDynamicCards: FixCard[] = [
},
]
// ── Viewport cards ────────────────────────────────
const viewportRuntimeCards: FixCard[] = [
{
id: 'use-static-viewport',
......@@ -354,7 +277,7 @@ const viewportRuntimeCards: FixCard[] = [
const viewportDynamicCards: FixCard[] = [
{
id: 'cache-viewport-data',
id: 'cache-the-viewport-data',
title: 'Cache the viewport data',
group: 'cache',
link: 'https://nextjs.org/docs/messages/blocking-prerender-viewport-dynamic#cache-the-viewport-data',
......@@ -378,8 +301,6 @@ const viewportDynamicCards: FixCard[] = [
},
]
// ── Sync IO cards (per API) ───────────────────────
const syncMathCards: FixCard[] = [
{
id: 'render-at-request-time',
......@@ -509,8 +430,6 @@ const syncCryptoCards: FixCard[] = [
},
]
// ── Client sync IO cards (no Suspense above) ──────
const syncClientDateCards: FixCard[] = [
{
id: 'wrap-in-or-move-into-suspense',
......@@ -604,8 +523,6 @@ const syncClientCryptoCards: FixCard[] = [
},
]
// ── Card lookup ───────────────────────────────────
export type GuidanceKind =
| 'blocking-route'
| 'client-hook'
......@@ -738,6 +655,16 @@ const syncClientCardsByCause: Record<string, FixCard[]> = {
"require('node:crypto').generateKeySync(...)": syncClientCryptoCards,
}
// `connection()`-triggered errors can't be cached.
function filterCacheForConnection(
cards: FixCard[],
variant: GuidanceVariant,
cause: string | undefined
): FixCard[] {
if (variant !== 'dynamic' || cause !== 'connection') return cards
return cards.filter((card) => card.group !== 'cache')
}
export function getCards(
kind: GuidanceKind,
variant: GuidanceVariant,
......@@ -745,15 +672,19 @@ export function getCards(
): FixCard[] {
switch (kind) {
case 'blocking-route':
return variant === 'dynamic' ? dynamicCards : runtimeCards
return variant === 'dynamic'
? filterCacheForConnection(dynamicCards, variant, cause)
: runtimeCards
case 'client-hook':
if (cause === 'useSearchParams()') return clientHookCardsSearchParams
if (cause === 'useParams()') return clientHookCardsWithGsp
return clientHookCardsNoGsp
return clientHookCards
case 'metadata':
return variant === 'runtime' ? metadataRuntimeCards : metadataDynamicCards
return variant === 'runtime'
? metadataRuntimeCards
: filterCacheForConnection(metadataDynamicCards, variant, cause)
case 'viewport':
return variant === 'runtime' ? viewportRuntimeCards : viewportDynamicCards
return variant === 'runtime'
? viewportRuntimeCards
: filterCacheForConnection(viewportDynamicCards, variant, cause)
case 'sync-io':
return (cause && syncCardsByCause[cause]) || []
case 'sync-io-client':
......
......@@ -17,12 +17,10 @@ import {
createSyncIORuntimeError,
type SyncIOApiType,
} from '../../../server/app-render/sync-io-messages'
import {
ClientHookDynamicError,
ParamClientHookDynamicError,
} from '../../../server/dynamic-rendering-utils'
import { ClientHookDynamicError } from '../../../server/dynamic-rendering-utils'
import { getCards } from '../components/instant/instant-guidance-data'
import {
deriveCauseFromCodeFrame,
getBlockingRouteErrorDetails,
getUnrenderedSegmentErrorDetails,
isInstantNavigationError,
......@@ -140,10 +138,10 @@ describe('getBlockingRouteErrorDetails', () => {
})
})
it('classifies param-derived client hook errors separately', () => {
it('classifies useParams() client hook errors', () => {
expect(
getBlockingRouteErrorDetails(
new ParamClientHookDynamicError(ROUTE, 'useParams()')
new ClientHookDynamicError(ROUTE, 'useParams()')
)
).toEqual({
type: 'client-hook',
......@@ -293,21 +291,16 @@ describe('client hook guidance', () => {
expect(cards.map((card) => card.group)).toEqual(['stream', 'block'])
})
it('shows Stream, GSP, and Block cards for useParams', () => {
it('shows Stream and Block cards for useParams', () => {
const cards = getCards('client-hook', 'runtime', 'useParams()')
expect(cards.map((card) => card.id)).toEqual([
'wrap-in-or-move-into-suspense',
'for-known-params-prerender',
'allow-blocking-route',
])
expect(cards.map((card) => card.group)).toEqual([
'stream',
'cache',
'block',
])
expect(cards.map((card) => card.group)).toEqual(['stream', 'block'])
})
it('shows Stream and Block cards for hooks without GSP', () => {
it('shows Stream and Block cards for hooks (no GSP)', () => {
const expected = ['wrap-in-or-move-into-suspense', 'allow-blocking-route']
expect(
getCards('client-hook', 'runtime', 'usePathname()').map((c) => c.id)
......@@ -329,37 +322,45 @@ describe('card sets for all error families', () => {
it('blocking-route runtime', () => {
expect(
getCards('blocking-route', 'runtime').map((card) => card.id)
).toEqual([
'wrap-in-or-move-into-suspense',
'for-known-params-prerender',
'allow-blocking-route',
])
).toEqual(['wrap-in-or-move-into-suspense', 'allow-blocking-route'])
})
it('blocking-route dynamic', () => {
expect(
getCards('blocking-route', 'dynamic').map((card) => card.id)
).toEqual([
'cache-the-component-or-data',
'wrap-in-or-move-into-suspense',
'cache-the-component-or-data',
'allow-blocking-route',
])
})
it('blocking-route dynamic with connection() drops the cache card', () => {
expect(
getCards('blocking-route', 'dynamic', 'connection').map((card) => card.id)
).toEqual(['wrap-in-or-move-into-suspense', 'allow-blocking-route'])
})
it('metadata runtime', () => {
expect(getCards('metadata', 'runtime').map((card) => card.id)).toEqual([
'use-static-metadata',
'render-page-at-request-time',
'mark-the-route-as-dynamic',
])
})
it('metadata dynamic', () => {
expect(getCards('metadata', 'dynamic').map((card) => card.id)).toEqual([
'cache-the-metadata',
'render-page-at-request-time',
'mark-the-route-as-dynamic',
])
})
it('metadata dynamic with connection() drops the cache card', () => {
expect(
getCards('metadata', 'dynamic', 'connection').map((card) => card.id)
).toEqual(['mark-the-route-as-dynamic'])
})
it('viewport runtime', () => {
expect(getCards('viewport', 'runtime').map((card) => card.id)).toEqual([
'use-static-viewport',
......@@ -369,11 +370,17 @@ describe('card sets for all error families', () => {
it('viewport dynamic', () => {
expect(getCards('viewport', 'dynamic').map((card) => card.id)).toEqual([
'cache-viewport-data',
'cache-the-viewport-data',
'allow-blocking-route',
])
})
it('viewport dynamic with connection() drops the cache card', () => {
expect(
getCards('viewport', 'dynamic', 'connection').map((card) => card.id)
).toEqual(['allow-blocking-route'])
})
it('unrendered-segment', () => {
expect(
getCards('unrendered-segment', 'runtime').map((card) => card.id)
......@@ -557,3 +564,57 @@ describe('isInstantNavigationError', () => {
expect(isInstantNavigationError(new Error('regular bug'))).toBe(false)
})
})
describe('deriveCauseFromCodeFrame', () => {
const connectionFrame = ` 3 | export default async function Page() {\n> 4 | await connection();\n | ^\n 5 | return <p>OK</p>;`
const fetchFrame = ` 1 | export default async function Page() {\n> 2 | const r = await fetch("/api");\n | ^\n 3 | return <p>{r.status}</p>;`
it('returns "connection" when the highlighted line calls connection()', () => {
expect(
deriveCauseFromCodeFrame('blocking-route', 'dynamic', connectionFrame)
).toBe('connection')
expect(
deriveCauseFromCodeFrame('metadata', 'dynamic', connectionFrame)
).toBe('connection')
expect(
deriveCauseFromCodeFrame('viewport', 'dynamic', connectionFrame)
).toBe('connection')
})
it('returns undefined when the highlighted line is a fetch/db call', () => {
expect(
deriveCauseFromCodeFrame('blocking-route', 'dynamic', fetchFrame)
).toBeUndefined()
})
it('returns undefined for runtime variant even if connection() is in scope', () => {
expect(
deriveCauseFromCodeFrame('blocking-route', 'runtime', connectionFrame)
).toBeUndefined()
})
it('returns undefined for kinds that do not show a cache card', () => {
expect(
deriveCauseFromCodeFrame('client-hook', 'dynamic', connectionFrame)
).toBeUndefined()
expect(
deriveCauseFromCodeFrame('sync-io', 'dynamic', connectionFrame)
).toBeUndefined()
})
it('returns undefined when there is no code frame', () => {
expect(
deriveCauseFromCodeFrame('blocking-route', 'dynamic', null)
).toBeUndefined()
expect(
deriveCauseFromCodeFrame('blocking-route', 'dynamic', undefined)
).toBeUndefined()
})
it('does not match when connection() appears only in a non-highlighted line', () => {
const frame = ` 1 | import { connection } from "next/server";\n> 2 | await fetch("/api");\n | ^`
expect(
deriveCauseFromCodeFrame('blocking-route', 'dynamic', frame)
).toBeUndefined()
})
})
......@@ -40,6 +40,7 @@ import { CodeFrame } from '../components/code-frame/code-frame'
import { ErrorOverlayCallStack } from '../components/errors/error-overlay-call-stack/error-overlay-call-stack'
import { ErrorCause } from './runtime-error/error-cause'
import { useFrames } from '../utils/get-error-by-type'
import stripAnsi from 'next/dist/compiled/strip-ansi'
import type { ErrorOverlayPaginationControls } from '../components/errors/error-overlay-pagination/error-overlay-pagination'
interface ErrorsProps extends ErrorBaseProps {
......@@ -248,6 +249,24 @@ function getHydrationErrorDetails(
}
}
// Detect `connection()` as the trigger by sniffing the highlighted line of the code frame.
export function deriveCauseFromCodeFrame(
kind: GuidanceKind,
variant: GuidanceVariant,
codeFrame: string | null | undefined
): 'connection' | undefined {
if (variant !== 'dynamic') return undefined
if (kind !== 'blocking-route' && kind !== 'metadata' && kind !== 'viewport')
return undefined
if (!codeFrame) return undefined
for (const line of stripAnsi(codeFrame).split('\n')) {
if (/^\s*>/.test(line) && /\bconnection\s*\(/.test(line)) {
return 'connection'
}
}
return undefined
}
function InstantRuntimeError({
error,
variant,
......@@ -279,6 +298,10 @@ function InstantRuntimeError({
return frames[idx] ?? null
}, [frames])
const derivedCause =
cause ??
deriveCauseFromCodeFrame(kind, variant, firstFrame?.originalCodeFrame)
return (
<>
{firstFrame && (
......@@ -291,7 +314,7 @@ function InstantRuntimeError({
variant={variant}
kind={kind}
explanation={explanation}
cause={cause}
cause={derivedCause}
showExplanation={showExplanation}
generateErrorInfo={generateErrorInfo}
/>
......
......@@ -5,8 +5,6 @@ export function createRuntimeBodyError(route: string): Error {
`Ways to fix this:\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense\n` +
` - [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender\n` +
` - [block] Set \`export const instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route`
)
......@@ -19,7 +17,7 @@ export function createDynamicBodyError(route: string): Error {
`Ways to fix this:\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense\n` +
` - [cache] Cache the data access with \`"use cache"\`\n` +
` - [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data\n` +
` - [block] Set \`export const instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route`
......@@ -33,8 +31,6 @@ export function createRuntimeBodyErrorInNavigation(route: string): Error {
`Ways to fix this:\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#wrap-in-or-move-into-suspense\n` +
` - [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender\n` +
` - [block] Set \`export const instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route`
)
......@@ -47,7 +43,7 @@ export function createDynamicBodyErrorInNavigation(route: string): Error {
`Ways to fix this:\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense\n` +
` - [cache] Cache the data access with \`"use cache"\`\n` +
` - [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data\n` +
` - [block] Set \`export const instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route`
......@@ -66,10 +62,8 @@ export function createDynamicOrRuntimeBodyError(route: string): Error {
`Ways to fix this:\n` +
` - [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense\n` +
` - [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`\n` +
` - [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\` (does not apply to \`connection()\`)\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data\n` +
` - [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender\n` +
` - [block] Set \`export const instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route`
)
......@@ -92,7 +86,7 @@ export function createDynamicMetadataError(route: string): Error {
`Route "${route}": Next.js encountered uncached data in \`generateMetadata()\`.\n\n` +
`This route's metadata is blocked, but the rest of its content can be prerendered. \`fetch(...)\` or \`connection()\` accessed in \`generateMetadata()\` cause it to run dynamically.\n\n` +
`Ways to fix this:\n` +
` - [cache] Cache the metadata with \`"use cache"\` in \`generateMetadata()\`\n` +
` - [cache] Cache the metadata with \`"use cache"\` in \`generateMetadata()\` (does not apply to \`connection()\`)\n` +
` https://nextjs.org/docs/messages/blocking-prerender-metadata-dynamic#cache-the-metadata\n` +
` - [dynamic] Render a marker component that calls \`await connection()\` inside \`<Suspense>\` on the page\n` +
` https://nextjs.org/docs/messages/blocking-prerender-metadata-dynamic#mark-the-route-as-dynamic`
......@@ -116,7 +110,7 @@ export function createDynamicViewportError(route: string): Error {
`Route "${route}": Next.js encountered uncached data in \`generateViewport()\`.\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` +
` - [cache] Cache the viewport data with \`"use cache"\` in \`generateViewport()\`\n` +
` - [cache] Cache the viewport data with \`"use cache"\` in \`generateViewport()\` (does not apply to \`connection()\`)\n` +
` https://nextjs.org/docs/messages/blocking-prerender-viewport-dynamic#cache-the-viewport-data\n` +
` - [block] Set \`export const instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-viewport-dynamic#allow-blocking-route`
......@@ -135,7 +129,7 @@ export function createDynamicOrRuntimeViewportError(route: string): Error {
`Ways to fix this:\n` +
` - [static] Use a static viewport export instead of \`generateViewport()\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-viewport-runtime#use-static-viewport\n` +
` - [cache] For uncached data (\`fetch\`, database calls): cache the viewport with \`"use cache"\` in \`generateViewport()\`\n` +
` - [cache] For uncached data (\`fetch\`, database calls): cache the viewport with \`"use cache"\` in \`generateViewport()\` (does not apply to \`connection()\`)\n` +
` https://nextjs.org/docs/messages/blocking-prerender-viewport-dynamic#cache-the-viewport-data\n` +
` - [block] Set \`export const instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-viewport-dynamic#allow-blocking-route`
......@@ -154,7 +148,7 @@ export function createDynamicOrRuntimeMetadataError(route: string): Error {
`Ways to fix this:\n` +
` - [static] Use a static metadata export instead of \`generateMetadata()\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-metadata-runtime#use-static-metadata\n` +
` - [cache] Cache the metadata with \`"use cache"\` in \`generateMetadata()\`\n` +
` - [cache] Cache the metadata with \`"use cache"\` in \`generateMetadata()\` (does not apply to \`connection()\`)\n` +
` https://nextjs.org/docs/messages/blocking-prerender-metadata-dynamic#cache-the-metadata\n` +
` - [dynamic] Render a marker component that calls \`await connection()\` inside \`<Suspense>\` on the page\n` +
` https://nextjs.org/docs/messages/blocking-prerender-metadata-dynamic#mark-the-route-as-dynamic`
......
......@@ -43,7 +43,6 @@ import {
ClientHookDynamicError,
isClientHookDynamicError,
makeClientHookHangingPromise,
ParamClientHookDynamicError,
} from '../dynamic-rendering-utils'
import {
METADATA_BOUNDARY_NAME,
......@@ -550,7 +549,7 @@ export function useDynamicRouteParams(expression: string) {
React.use(
makeClientHookHangingPromise(
workUnitStore.renderSignal,
new ParamClientHookDynamicError(workStore.route, expression)
new ClientHookDynamicError(workStore.route, expression)
)
)
}
......
......@@ -52,31 +52,9 @@ export class ClientHookDynamicError extends Error {
}
}
export class ParamClientHookDynamicError extends Error {
public readonly digest = CLIENT_HOOK_DYNAMIC
constructor(route: string, expression: string) {
const cacheBullet =
expression === 'useParams()'
? ` - [cache] For known params, prerender them with \`generateStaticParams\`\n` +
` https://nextjs.org/docs/messages/blocking-prerender-client-hook#for-known-params-prerender\n`
: ''
super(
`Route "${route}": Next.js encountered URL data \`${expression}\` in a Client Component outside of \`<Suspense>\`.\n\n` +
`This blocks prerendering because the value is only available at runtime.\n\n` +
`Ways to fix this:\n` +
` - [stream] Wrap the component in \`<Suspense fallback={...}>\` so the hook value streams in after prerendering\n` +
` https://nextjs.org/docs/messages/blocking-prerender-client-hook#wrap-in-or-move-into-suspense\n` +
cacheBullet +
` - [block] Set \`export const instant = false\` to silence this warning and allow a blocking route\n` +
` https://nextjs.org/docs/messages/blocking-prerender-client-hook#allow-blocking-route`
)
}
}
export function isClientHookDynamicError(
err: unknown
): err is ClientHookDynamicError | ParamClientHookDynamicError {
): err is ClientHookDynamicError {
if (typeof err !== 'object' || err === null || !('digest' in err)) {
return false
}
......@@ -107,7 +85,7 @@ export function makeHangingPromise<T>(
export function makeClientHookHangingPromise<T>(
signal: AbortSignal,
error: ClientHookDynamicError | ParamClientHookDynamicError
error: ClientHookDynamicError
): Promise<T> {
return makeHangingPromiseWithError(signal, error)
}
......
......@@ -98,7 +98,7 @@ describe('Cache Components Dev Errors', () => {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1318",
"code": "E1373",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......
......@@ -52,7 +52,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -67,7 +67,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -85,7 +85,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -100,7 +100,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -118,7 +118,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -133,7 +133,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -155,7 +155,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -170,7 +170,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -188,7 +188,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -203,7 +203,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -221,7 +221,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -236,7 +236,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -254,7 +254,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -269,7 +269,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -287,7 +287,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -302,7 +302,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -320,7 +320,7 @@ describe('Cache Components Fallback Validation', () => {
if (isTurbopack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -335,7 +335,7 @@ describe('Cache Components Fallback Validation', () => {
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1320",
"code": "E1368",
"description": "Next.js encountered runtime data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......
......@@ -229,7 +229,7 @@ describe('cache-components-dev-streaming', () => {
// Cold cache miss: validation runs against a separate warm-cache render.
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1318",
"code": "E1373",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -254,7 +254,7 @@ describe('cache-components-dev-streaming', () => {
// and the cached value is re-served rather than recomputed.
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1318",
"code": "E1373",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......
......@@ -81,7 +81,7 @@ describe('Cache Components Errors - Client Components', () => {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1318",
"code": "E1373",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -118,10 +118,8 @@ describe('Cache Components Errors - Client Components', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at Client (app/client-awaited-io/client.tsx:6:19)
......@@ -148,10 +146,8 @@ describe('Cache Components Errors - Client Components', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at <unknown> (app/client-awaited-io/client.tsx:5:26)
......@@ -181,10 +177,8 @@ describe('Cache Components Errors - Client Components', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at Client (webpack:///app/client-awaited-io/client.tsx:6:19)
......@@ -211,10 +205,8 @@ describe('Cache Components Errors - Client Components', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at a (<next-dist-dir>)
......@@ -411,7 +403,7 @@ describe('Cache Components Errors - Client Components', () => {
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1315",
"code": "E1316",
"description": "Next.js encountered URL data usePathname() in a Client Component outside of Suspense.",
"environmentLabel": "Server",
"label": "Blocking Route",
......
......@@ -71,7 +71,7 @@ describe('instant-validation-build', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
- [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......
......@@ -105,7 +105,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -136,7 +136,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -167,7 +167,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -201,7 +201,7 @@ describe('instant validation causes', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......
......@@ -57,7 +57,7 @@ describe('instant validation - default level', () => {
const browser = await next.browser('/bare')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached 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": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -90,7 +90,7 @@ describe('instant validation - level error', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -120,7 +120,7 @@ describe('instant validation - level error', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -150,7 +150,7 @@ describe('instant validation - level error', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"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": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -204,7 +204,7 @@ describe('instant validation - level error', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
- [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......@@ -231,7 +231,7 @@ describe('instant validation - level error', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
- [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......@@ -258,7 +258,7 @@ describe('instant validation - level error', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
- [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......@@ -298,7 +298,7 @@ describe('instant validation - level error', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
- [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......
......@@ -79,7 +79,7 @@ describe('instant validation - level manual-error', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -109,7 +109,7 @@ describe('instant validation - level manual-error', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -139,7 +139,7 @@ describe('instant validation - level manual-error', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -187,7 +187,7 @@ describe('instant validation - level manual-error', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
- [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......@@ -214,7 +214,7 @@ describe('instant validation - level manual-error', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
- [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......
......@@ -93,7 +93,7 @@ describe('instant validation - level manual-warning', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -125,7 +125,7 @@ describe('instant validation - level manual-warning', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -157,7 +157,7 @@ describe('instant validation - level manual-warning', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -199,7 +199,7 @@ describe('instant validation - level manual-warning', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
- [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......@@ -230,7 +230,7 @@ describe('instant validation - level manual-warning', () => {
// did not run under 'manual-warning'.
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1318",
"code": "E1373",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -250,7 +250,7 @@ describe('instant validation - level manual-warning', () => {
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1318",
"code": "E1373",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -270,7 +270,7 @@ describe('instant validation - level manual-warning', () => {
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1318",
"code": "E1373",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -290,7 +290,7 @@ describe('instant validation - level manual-warning', () => {
)
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1318",
"code": "E1373",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......@@ -338,10 +338,8 @@ describe('instant validation - level manual-warning', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at body (<anonymous>)
......@@ -366,10 +364,8 @@ describe('instant validation - level manual-warning', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at body (<anonymous>)
......@@ -396,10 +392,8 @@ describe('instant validation - level manual-warning', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at body (<anonymous>)
......@@ -430,10 +424,8 @@ describe('instant validation - level manual-warning', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\`
- [cache] For uncached data (\`fetch\`, database calls): cache the access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
at body (<anonymous>)
......
......@@ -60,7 +60,7 @@ describe('instant validation - level warning', () => {
const browser = await next.browser('/bare')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -90,7 +90,7 @@ describe('instant validation - level warning', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -120,7 +120,7 @@ describe('instant validation - level warning', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -150,7 +150,7 @@ describe('instant validation - level warning', () => {
],
},
],
"code": "E1317",
"code": "E1375",
"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": "E1317",
"code": "E1375",
"description": "Next.js encountered uncached data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -209,7 +209,7 @@ describe('instant validation - level warning', () => {
Ways to fix this:
- [stream] Provide a placeholder with \`<Suspense fallback={...}>\` around the data access
https://nextjs.org/docs/messages/blocking-prerender-dynamic#wrap-in-or-move-into-suspense
- [cache] Cache the data access with \`"use cache"\`
- [cache] Cache the data access with \`"use cache"\` (does not apply to \`connection()\`)
https://nextjs.org/docs/messages/blocking-prerender-dynamic#cache-the-component-or-data
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-dynamic#allow-blocking-route
......
......@@ -45,7 +45,7 @@ describe('instant validation', () => {
await browser.elementByCss('main')
await expect(browser).toDisplayCollapsedRedbox(`
{
"code": "E1318",
"code": "E1373",
"description": "Next.js encountered uncached data during prerendering.",
"environmentLabel": "Server",
"label": "Blocking Route",
......
......@@ -124,7 +124,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -149,8 +149,6 @@ describe('instant validation - parallel slot configs', () => {
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
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
at body (<anonymous>)
......@@ -185,7 +183,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -210,8 +208,6 @@ describe('instant validation - parallel slot configs', () => {
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
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
at body (<anonymous>)
......@@ -246,7 +242,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -271,8 +267,6 @@ describe('instant validation - parallel slot configs', () => {
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
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
at body (<anonymous>)
......@@ -309,7 +303,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -334,8 +328,6 @@ describe('instant validation - parallel slot configs', () => {
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
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
at div (<anonymous>)
......@@ -372,7 +364,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -396,7 +388,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -422,8 +414,6 @@ describe('instant validation - parallel slot configs', () => {
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
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
at div (<anonymous>)
......@@ -437,8 +427,6 @@ describe('instant validation - parallel slot configs', () => {
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
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
at body (<anonymous>)
......@@ -541,7 +529,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......@@ -564,8 +552,6 @@ describe('instant validation - parallel slot configs', () => {
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
- [cache] For \`params\`: if the params are known, prerender them with \`generateStaticParams\`
https://nextjs.org/docs/messages/blocking-prerender-runtime#for-known-params-prerender
- [block] Set \`export const instant = false\` to silence this warning and allow a blocking route
https://nextjs.org/docs/messages/blocking-prerender-runtime#allow-blocking-route
at div (<anonymous>)
......@@ -635,7 +621,7 @@ describe('instant validation - parallel slot configs', () => {
],
},
],
"code": "E1319",
"code": "E1372",
"description": "Next.js encountered runtime data during a navigation.",
"environmentLabel": "Server",
"label": "Instant",
......
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