mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This restores fast navigations to fully static PPR routes in Cache
Components, even when prefetch hasn’t completed or `prefetch={false}` is
used. In legacy versions of PPR, the `prefetchDataRoute` entries would
be populated with `.prefetch.rsc` values containing static RSC payloads.
This regressed in cache components, and the only static RSC payloads
were in the `.segments` directory. However, when Next.js triggers a
regular RSC request (non-prefetch), either because the prefetch hadn't
completed yet or `prefetch={false}` was configured, we'd route to the
empty fallback and trigger a function invocation.
This restores old behavior of emitting a `.rsc` file for a fully static
route. This information technically also exists in the `.segments`
directory, but it's split into parts, and it's now routed to unless
explicitly done so via the `next-router-segment-prefetch` header. In
addition to emitting the route, this also ensures we set
`prefetchDataRoute` to point to this. This is how the Vercel adapter
knows the file to serve.
An e2e regression test now asserts that `prefetch={false}` navigation
does not wait for a dynamic render. The deploy test will be unblocked
once https://github.com/vercel/vercel/pull/14770 lands.
32 lines
940 B
TypeScript
32 lines
940 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('static-rsc-cache-components', () => {
|
|
const { next, isNextDev } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
if (isNextDev) {
|
|
it('is skipped', () => {})
|
|
return
|
|
}
|
|
|
|
it('navigates to prerendered route without waiting for dynamic render', async () => {
|
|
const browser = await next.browser('/')
|
|
|
|
// Track elapsed time across the client navigation.
|
|
await browser.eval(`window.__navStart = performance.now()`)
|
|
|
|
const link = await browser.elementByCss('a[href="/alpha"]')
|
|
await link.click()
|
|
|
|
const slug = await browser.elementById('slug')
|
|
expect(await slug.innerText()).toBe('Hi alpha')
|
|
|
|
const elapsed = await browser.eval(`performance.now() - window.__navStart`)
|
|
|
|
// The page has an intentional 2s delay in the Server Component.
|
|
// If this were a dynamic render, navigation would take ~2s+.
|
|
expect(elapsed).toBeLessThan(1500)
|
|
})
|
|
})
|