mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Fixes an oversight where `params`/`searchParams` in client pages would
cause dev instant validation to go down a codepath intended for
build-time instant validation. We'd end up unintentionally wrapping
params with an excaustive proxy which would then crash because the store
is not set up as expected:
```
## Error Message
Route "/store/[slug]": Could not validate `instant` because an error prevented the target segment from rendering.
Next.js version: 16.3.0-preview.5 (Turbopack)
[cause]: Error [InvariantError]: Invariant: Expected to have a workUnitStore that provides validationSampleTracking. This is a bug in Next.js.
at Page (app/store/[slug]/page.tsx:6:11)
4 |
5 | export default function Page(props: PageProps<"/store/[slug]">) {
> 6 | const { slug } = use(props.params);
| ^
7 | return (
8 | <>
9 | <h1>Store {slug}</h1>
}
```
The proxy code should've been gated on `workUnitStore.validationSamples`
like we do in other places that care about samples.
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { connection } from 'next/server'
|
|
import { cacheLife } from 'next/cache'
|
|
import Link from 'next/link'
|
|
import { Suspense } from 'react'
|
|
import { setTimeout } from 'timers/promises'
|
|
|
|
export function HackilyPreventFullyStaticServerPrerender() {
|
|
// FIXME(NAR-800)
|
|
return <Suspense>{connection().then(() => null)}</Suspense>
|
|
}
|
|
|
|
export function RootLayoutTimestamp() {
|
|
const timestamp = performance.timeOrigin + performance.now()
|
|
return <div id="root-layout-timestamp">{timestamp}</div>
|
|
}
|
|
|
|
export function DebugLinks({ href }: { href: string }) {
|
|
return (
|
|
<span>
|
|
<span>{href}</span>{' '}
|
|
<Link data-link-type="soft" href={href}>
|
|
[SPA]
|
|
</Link>{' '}
|
|
<a data-link-type="hard" href={href}>
|
|
[MPA]
|
|
</a>
|
|
</span>
|
|
)
|
|
}
|
|
|
|
export async function uncachedIO() {
|
|
await setTimeout(0)
|
|
}
|
|
|
|
export async function cachedDelay(key: any) {
|
|
'use cache'
|
|
cacheLife('minutes')
|
|
await setTimeout(1)
|
|
}
|
|
|
|
export function DebugRenderKind() {
|
|
const { workUnitAsyncStorage } =
|
|
require('next/dist/server/app-render/work-unit-async-storage.external') as typeof import('next/dist/server/app-render/work-unit-async-storage.external')
|
|
const workUnitStore = workUnitAsyncStorage.getStore()!
|
|
return (
|
|
<div>
|
|
workUnitStore.type: {workUnitStore.type}
|
|
{(() => {
|
|
switch (workUnitStore.type) {
|
|
case 'prerender':
|
|
return '(static prefetch)'
|
|
case 'prerender-runtime':
|
|
return '(runtime prefetch)'
|
|
default:
|
|
return null
|
|
}
|
|
})()}
|
|
</div>
|
|
)
|
|
}
|