Files
next.js/test/e2e/app-dir/static-rsc-cache-components/static-rsc-cache-components.test.ts
Zack TannerandGitHub b0ebf2a822 fix: fully static pages should emit & serve static rsc payloads (#89202)
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.
2026-01-29 14:26:40 -08:00

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)
})
})