Unverified Commit e974969d authored by Janka Uryga's avatar Janka Uryga Committed by GitHub

[PPF] Model caches with `stale < MIN_SHELL_STALE` as prefetch-only data (#98339)

Caches that have `stale < MIN_SHELL_STALE` were using
`makeStageHangingPromise` in prerenders, which (in theory) was meant to
track a runtime data access during a static prerender, which in turn
would make the page use runtime shells. This is semantically incorrect,
because both static and runtime shells would exclude the cache, and both
static and runtime prefetches would include it, so it does not actually
signal runtimeness, only prefetchness. The only thing we should be doing
for these caches is excluding the content, same as
`unstable_prefetch()`.

This PR replaces `makeStageHangingPromise` with
`makePrefetchHangingPromise`, which is not tracked as runtime data at
all. We also use it for `unstable_prefetch()` to signal the
correspondence.

Note that in practice, the usage of `makeStageHangingPromise` in
`use-cache-wrapper` was *technically* fine, because its runtime data
tracking was effectively dead code. We only returned it if
`stagedRendering.finalStage < stage`, but for static prerenders `stage =
staticLinkDataStage = PrefetchStatic` and `finalStage = Static`, so the
condition was never actually true, and we never actually tracked it as a
runtime data access. However semantically it should still not be tracked
as runtime data.
(The condition *can* be true in a runtime prerender that only prerenders
the shell. We don't do any tracking in runtime prerenders, so it was
also a no-op).

(this was extracted from #98129, where we separate runtime data access
tracking into session data and URL data. i couldn't figure which one
`makeStageHangingPromise` should be tracked as, but then i realized it
shouldn't be tracked at all)
parent aab93871
...@@ -187,31 +187,18 @@ export function makeFallbackParamsHangingPromise<T>( ...@@ -187,31 +187,18 @@ export function makeFallbackParamsHangingPromise<T>(
/** /**
* Constructs a promise that never resolves, standing in for data that is only * Constructs a promise that never resolves, standing in for data that is only
* accessible in a later *stage* of rendering than this render reaches — e.g. * accessible in the prefetch, but not in the shell, e.g. `unstable_prefetch()`.
* a prefetchable short-stale cache entry that's excluded from shells when the * This usage does *not* indicate that a runtime request is needed,
* render ends at the shell stage, or params during a runtime-prefetch render * only that the data is not available in a shell.
* that stops before the stage where params resolve.
*
* A render that runs through the later stage would include the data; in
* particular a runtime prefetch renders through its later stages, so on a
* static prerender store awaiting this promise records `runtimeDataAccessed`,
* same as `makeRuntimeHangingPromise`.
* *
* @internal * @internal
*/ */
export function makeStageHangingPromise<T>( export function makePrefetchHangingPromise<T>(
signal: AbortSignal, signal: AbortSignal,
route: string, route: string,
expression: string, expression: string
workUnitStore: WorkUnitStore
): Promise<T> { ): Promise<T> {
return trackPromiseUsed( return makeUntrackedHangingPromise(signal, route, expression)
makeHangingPromiseWithError<T>(
signal,
new HangingPromiseRejectionError(route, expression)
),
trackRuntimeDataAccessed.bind(null, workUnitStore, expression)
)
} }
/** /**
......
...@@ -141,6 +141,7 @@ export function createDefaultCacheHandler(maxSize: number): CacheHandler { ...@@ -141,6 +141,7 @@ export function createDefaultCacheHandler(maxSize: number): CacheHandler {
timestamp: entry.timestamp, timestamp: entry.timestamp,
expire: entry.expire, expire: entry.expire,
revalidate, revalidate,
stale: entry.stale,
}) })
return { return {
......
...@@ -5,6 +5,7 @@ import { ...@@ -5,6 +5,7 @@ import {
} from '../app-render/work-unit-async-storage.external' } from '../app-render/work-unit-async-storage.external'
import { import {
applyOwnerStack, applyOwnerStack,
makePrefetchHangingPromise,
makeUntrackedHangingPromise, makeUntrackedHangingPromise,
RENDER_STAGES_BY_DATA_KIND, RENDER_STAGES_BY_DATA_KIND,
trackIncompatibleShellContent, trackIncompatibleShellContent,
...@@ -76,7 +77,7 @@ export function unstable_prefetch(): Promise<void> { ...@@ -76,7 +77,7 @@ export function unstable_prefetch(): Promise<void> {
// Prospective prerender // Prospective prerender
// Make sure we don't unblock content that won't be reached in the final prerender. // Make sure we don't unblock content that won't be reached in the final prerender.
if (workUnitStore.finalStage < prefetchStage) { if (workUnitStore.finalStage < prefetchStage) {
return makeUntrackedHangingPromise( return makePrefetchHangingPromise(
workUnitStore.renderSignal, workUnitStore.renderSignal,
workStore.route, workStore.route,
'`unstable_prefetch()`' '`unstable_prefetch()`'
......
...@@ -42,7 +42,7 @@ import { ...@@ -42,7 +42,7 @@ import {
makeDevtoolsIOAwarePromise, makeDevtoolsIOAwarePromise,
makeDynamicHangingPromise, makeDynamicHangingPromise,
makeRuntimeHangingPromise, makeRuntimeHangingPromise,
makeStageHangingPromise, makePrefetchHangingPromise,
makeUntrackedHangingPromise, makeUntrackedHangingPromise,
RENDER_STAGES_BY_DATA_KIND, RENDER_STAGES_BY_DATA_KIND,
} from '../dynamic-rendering-utils' } from '../dynamic-rendering-utils'
...@@ -2528,23 +2528,7 @@ export async function cache( ...@@ -2528,23 +2528,7 @@ export async function cache(
case 'prerender': case 'prerender':
case 'prerender-runtime': { case 'prerender-runtime': {
const prerenderStore = workUnitStore const prerenderStore = workUnitStore
// The post-shell stage that the entry must be delayed to. if (!isPrefetchable) {
let postShellStage: AdvanceableRenderStage
if (prerenderStore.type === 'prerender') {
postShellStage = RENDER_STAGES_BY_DATA_KIND.staticLinkData
} else {
postShellStage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData
}
const stagedRendering = prerenderStore.stagedRendering
if (
!isPrefetchable ||
// If the render ends before the post-shell stage (e.g. a
// render that only produces an App Shell), the entry can't
// be delayed and is omitted entirely.
(stagedRendering !== null &&
stagedRendering.finalStage !== null &&
stagedRendering.finalStage < postShellStage)
) {
debug?.( debug?.(
logPrefix, logPrefix,
'omitting entry', 'omitting entry',
...@@ -2555,35 +2539,68 @@ export async function cache( ...@@ -2555,35 +2539,68 @@ export async function cache(
if (cacheSignal) { if (cacheSignal) {
cacheSignal.endRead() cacheSignal.endRead()
} }
if (isPrefetchable) {
// The entry was omitted only because this render ends
// before the post-shell stage; a render that reaches its
// post-shell stage would serve it.
return makeStageHangingPromise(
prerenderStore.renderSignal,
workStore.route,
'dynamic "use cache"',
prerenderStore
)
}
// An unprefetchable entry (stale < MIN_PREFETCHABLE_STALE) is // An unprefetchable entry (stale < MIN_PREFETCHABLE_STALE) is
// excluded from runtime prerenders too. // excluded from all prerenders.
return makeDynamicHangingPromise( return makeDynamicHangingPromise(
prerenderStore.renderSignal, prerenderStore.renderSignal,
workStore.route, workStore.route,
'dynamic "use cache"' 'dynamic "use cache"'
) )
} else {
// This entry is prefetchable, but exluded from shells.
const stagedRendering = prerenderStore.stagedRendering
if (stagedRendering === null) {
// Prospective prerender (no staging): do not delay, because if we didn't
// have this entry in the RDC already, we wouldn't delay it either.
} else {
// Final prerender (with staging).
// This entry cannot be part of the shell, so we delay it to the prefetch.
let prefetchStage: AdvanceableRenderStage
if (prerenderStore.type === 'prerender') {
prefetchStage = RENDER_STAGES_BY_DATA_KIND.staticLinkData
} else {
prefetchStage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData
}
if (
// If the prerender ends before the prefetch stage (because
// render that only produces an App Shell), this cache
// should be omitted entirely.
stagedRendering.finalStage !== null &&
stagedRendering.finalStage < prefetchStage
) {
debug?.(
logPrefix,
'omitting entry',
serializedCacheKey,
'from shell due to short stale value:',
rdcResult.entry.stale
)
if (cacheSignal) {
cacheSignal.endRead()
}
// The entry was omitted only because this prerender ends
// before the prefetch stage. Neither static nor runtime
// app shells include it, so it does not count as a runtime
// data access.
return makePrefetchHangingPromise(
prerenderStore.renderSignal,
workStore.route,
'dynamic "use cache"'
)
} else {
debug?.(
logPrefix,
'delaying entry',
serializedCacheKey,
'until the prefetch stage due to short stale value:',
rdcResult.entry.stale
)
await stagedRendering.waitForStage(prefetchStage)
}
}
} }
if (stagedRendering !== null) {
debug?.(
logPrefix,
'delaying entry',
serializedCacheKey,
'until after the shell stage due to short stale value:',
rdcResult.entry.stale
)
await stagedRendering.waitForStage(postShellStage)
}
break break
} }
case 'request': { case 'request': {
......
import { Suspense } from 'react'
import { cachedDelay, DebugRenderKind } from '../../../shared'
import { cacheLife } from 'next/cache'
export const instant = true
export const prefetch = 'partial'
export default async function Page() {
return (
<main>
<DebugRenderKind />
<p id="intro">
This page uses a private cache (stale &lt; MIN_SHELL_STALE, 5min), which
should not be included in a runtime shell, but it should be included in
a runtime prefetch.
</p>
<Suspense fallback={<div style={{ color: 'grey' }}>Loading...</div>}>
<NonShellCache />
</Suspense>
</main>
)
}
async function NonShellCache() {
'use cache: private'
cacheLife({
stale: 5 * 60 - 1, // < MIN_SHELL_STALE
})
await cachedDelay([__filename])
return <div id="cached-value">Non-shell cached content</div>
}
import { Suspense } from 'react'
import { cachedDelay, DebugRenderKind } from '../../../shared'
import { cacheLife } from 'next/cache'
import { ForceRuntimeShell } from '../../../../components/force-runtime-shell'
export const instant = true
export const prefetch = 'partial'
export default async function Page() {
return (
<main>
<DebugRenderKind />
{/*
A page that uses public caches that are excluded from the shell can still be
statically prerendered, so we have to force it to use runtime requests instead.
*/}
<ForceRuntimeShell />
<p id="intro">
This page uses a public cache (stale &lt; MIN_SHELL_STALE, 5min), which
should not be included in a runtime shell, but it should be included in
a runtime prefetch.
</p>
<Suspense fallback={<div style={{ color: 'grey' }}>Loading...</div>}>
<NonShellCache />
</Suspense>
</main>
)
}
async function NonShellCache() {
'use cache'
cacheLife({
stale: 5 * 60 - 1, // < MIN_SHELL_STALE
})
await cachedDelay([__filename])
return <div id="cached-value">Non-shell cached content</div>
}
...@@ -214,30 +214,33 @@ export default async function Page() { ...@@ -214,30 +214,33 @@ export default async function Page() {
<h2>short-lived caches</h2> <h2>short-lived caches</h2>
<ul> <ul>
<li> <li>
private, short stale private, non-prefetchable stale
<ul> <ul>
<li> <li>
<DebugLinkAccordion href="/caches/private-short-stale" prefetch /> <DebugLinkAccordion
href="/caches/private-non-prefetchable-stale"
prefetch
/>
</li> </li>
</ul> </ul>
</li> </li>
<li> <li>
public, short expire, long enough stale public, short expire, prefetchable stale
<ul> <ul>
<li> <li>
<DebugLinkAccordion <DebugLinkAccordion
href="/caches/public-short-expire-long-stale" href="/caches/public-short-expire-prefetchable-stale"
prefetch prefetch
/> />
</li> </li>
</ul> </ul>
</li> </li>
<li> <li>
public, short expire, short stale public, short expire, non-prefetchable stale
<ul> <ul>
<li> <li>
<DebugLinkAccordion <DebugLinkAccordion
href="/caches/public-short-expire-short-stale" href="/caches/public-short-expire-non-prefetchable-stale"
prefetch prefetch
/> />
</li> </li>
...@@ -259,6 +262,28 @@ export default async function Page() { ...@@ -259,6 +262,28 @@ export default async function Page() {
</li> </li>
</ul> </ul>
</li> </li>
<li>
public, non-shell stale
<ul>
<li>
<DebugLinkAccordion
href="/caches/public-non-shell-stale"
prefetch
/>
</li>
</ul>
</li>
<li>
private, non-shell stale
<ul>
<li>
<DebugLinkAccordion
href="/caches/private-non-shell-stale"
prefetch
/>
</li>
</ul>
</li>
</ul> </ul>
<h2>misc</h2> <h2>misc</h2>
......
import { cookies } from 'next/headers'
import { Suspense } from 'react'
/** Forces the page to use a runtime shell by using cookies. */
export function ForceRuntimeShell() {
return (
<Suspense>
<Inner />
</Suspense>
)
}
async function Inner() {
await cookies()
return null
}
...@@ -727,7 +727,7 @@ describe('runtime prefetching', () => { ...@@ -727,7 +727,7 @@ describe('runtime prefetching', () => {
) )
}) })
describe('cache stale time handling', () => { describe('excluded caches', () => {
it.each([ it.each([
{ {
// If a cache has an expiration time under 5min // If a cache has an expiration time under 5min
...@@ -735,9 +735,9 @@ describe('runtime prefetching', () => { ...@@ -735,9 +735,9 @@ describe('runtime prefetching', () => {
// However, it should still be included in a runtime prefetch if its // However, it should still be included in a runtime prefetch if its
// stale time is >=30s. (MIN_PREFETCHABLE_STALE) // stale time is >=30s. (MIN_PREFETCHABLE_STALE)
description: description:
'includes short-lived public caches with a long enough staleTime', 'includes short-lived public caches with a prefetchable staleTime',
staticContent: 'This page uses a short-lived public cache', staticContent: 'This page uses a short-lived public cache',
path: '/caches/public-short-expire-long-stale', path: '/caches/public-short-expire-prefetchable-stale',
}, },
{ {
// If a cache has an expiration time under 5min // If a cache has an expiration time under 5min
...@@ -798,7 +798,63 @@ describe('runtime prefetching', () => { ...@@ -798,7 +798,63 @@ describe('runtime prefetching', () => {
) )
}) })
it('omits short-lived public caches with a short enough staleTime', async () => { it.each([
{
description:
'includes public caches whose staleTime was too short to include in a shell',
staticContent: 'This page uses a public cache',
path: '/caches/public-non-shell-stale',
},
{
description:
'includes private caches whose staleTime was too short to include in a shell',
staticContent: 'This page uses a private cache',
path: '/caches/private-non-shell-stale',
},
])('$description', async ({ path, staticContent }) => {
let page: Playwright.Page
const browser = await next.browser('/', {
beforePageLoad(p: Playwright.Page) {
page = p
},
})
const act = createRouterAct(page, { includeAppShellRequests: true })
// Reveal the link to trigger a runtime prefetch.
await act(async () => {
await browser
.elementByCss(`input[data-link-accordion="${path}"]`)
.click()
}, [
// Shell request
{
includes: staticContent,
kind: 'runtime',
},
// Prefetch request
// (the shell was not complete, because the cache was excluded from it)
{
includes: 'Non-shell cached content',
kind: 'runtime',
},
])
// The cache should be displayed while navigating and after.
await act(
async () => {
await browser.elementByCss(`a[href="${path}"]`).click()
expect(await browser.elementById('cached-value').text()).toBe(
'Non-shell cached content'
)
},
// The prefetch was complete.
'no-requests'
)
expect(await browser.elementById('cached-value').text()).toBe(
'Non-shell cached content'
)
})
it('omits short-lived public caches with a non-prefetchable staleTime', async () => {
// If a cache has a stale time below 30s (MIN_PREFETCHABLE_STALE), we // If a cache has a stale time below 30s (MIN_PREFETCHABLE_STALE), we
// should omit it from runtime prefetches. // should omit it from runtime prefetches.
...@@ -816,7 +872,7 @@ describe('runtime prefetching', () => { ...@@ -816,7 +872,7 @@ describe('runtime prefetching', () => {
// Reveal the link to trigger a runtime prefetch. // Reveal the link to trigger a runtime prefetch.
await act(async () => { await act(async () => {
const linkToggle = await browser.elementByCss( const linkToggle = await browser.elementByCss(
`input[data-link-accordion="/caches/public-short-expire-short-stale"]` `input[data-link-accordion="/caches/public-short-expire-non-prefetchable-stale"]`
) )
await linkToggle.click() await linkToggle.click()
}, [ }, [
...@@ -837,7 +893,9 @@ describe('runtime prefetching', () => { ...@@ -837,7 +893,9 @@ describe('runtime prefetching', () => {
await act( await act(
async () => { async () => {
await browser await browser
.elementByCss(`a[href="/caches/public-short-expire-short-stale"]`) .elementByCss(
`a[href="/caches/public-short-expire-non-prefetchable-stale"]`
)
.click() .click()
}, },
{ {
...@@ -859,7 +917,7 @@ describe('runtime prefetching', () => { ...@@ -859,7 +917,7 @@ describe('runtime prefetching', () => {
expect(await browser.elementById('cached-value').text()).toMatch(/\d+/) expect(await browser.elementById('cached-value').text()).toMatch(/\d+/)
}) })
it('omits private caches with a short enough staleTime', async () => { it('omits private caches with a non-prefetchable staleTime', async () => {
// If a cache has a stale time below 30s (MIN_PREFETCHABLE_STALE), we // If a cache has a stale time below 30s (MIN_PREFETCHABLE_STALE), we
// should omit it from runtime prefetches. // should omit it from runtime prefetches.
...@@ -877,7 +935,7 @@ describe('runtime prefetching', () => { ...@@ -877,7 +935,7 @@ describe('runtime prefetching', () => {
// Reveal the link to trigger a runtime prefetch // Reveal the link to trigger a runtime prefetch
await act(async () => { await act(async () => {
const linkToggle = await browser.elementByCss( const linkToggle = await browser.elementByCss(
`input[data-link-accordion="/caches/private-short-stale"]` `input[data-link-accordion="/caches/private-non-prefetchable-stale"]`
) )
await linkToggle.click() await linkToggle.click()
}, [ }, [
...@@ -898,7 +956,7 @@ describe('runtime prefetching', () => { ...@@ -898,7 +956,7 @@ describe('runtime prefetching', () => {
await act( await act(
async () => { async () => {
await browser await browser
.elementByCss(`a[href="/caches/private-short-stale"]`) .elementByCss(`a[href="/caches/private-non-prefetchable-stale"]`)
.click() .click()
}, },
{ {
...@@ -926,7 +984,7 @@ describe('runtime prefetching', () => { ...@@ -926,7 +984,7 @@ describe('runtime prefetching', () => {
// Hover the link again. The prefetch should be cached, so we shouldn't see any requests // Hover the link again. The prefetch should be cached, so we shouldn't see any requests
await act(async () => { await act(async () => {
const linkToggle = await browser.elementByCss( const linkToggle = await browser.elementByCss(
`input[data-link-accordion="/caches/private-short-stale"]` `input[data-link-accordion="/caches/private-non-prefetchable-stale"]`
) )
await linkToggle.hover() await linkToggle.hover()
}, 'no-requests') }, 'no-requests')
...@@ -936,7 +994,7 @@ describe('runtime prefetching', () => { ...@@ -936,7 +994,7 @@ describe('runtime prefetching', () => {
await act( await act(
async () => { async () => {
await browser await browser
.elementByCss(`a[href="/caches/private-short-stale"]`) .elementByCss(`a[href="/caches/private-non-prefetchable-stale"]`)
.click() .click()
}, },
{ {
......
import { Suspense } from 'react'
import { cacheLife } from 'next/cache'
export default function Page() {
return (
<main>
<p id="page-content">Uses a cache that is excluded from all prerenders</p>
<Suspense fallback={<p id="cache-loading">Loading cache...</p>}>
<CacheContent />
</Suspense>
</main>
)
}
async function CacheContent() {
const value = await nonPrefetchableCache()
return <div id="cache-content">{`Cache value: ${value}`}</div>
}
async function nonPrefetchableCache() {
'use cache'
cacheLife({ stale: 30 - 1 }) // smaller than MIN_PREFETCHABLE_STALE
await new Promise((resolve) => setTimeout(resolve))
return Date.now()
}
import { Suspense } from 'react'
import { cacheLife } from 'next/cache'
export default function Page() {
return (
<main>
<p id="page-content">
Uses a cache that is excluded from static prerenders, but included in
runtime ones
</p>
<Suspense fallback={<p id="cache-loading">Loading cache...</p>}>
<CacheContent />
</Suspense>
</main>
)
}
async function CacheContent() {
const value = await nonPrerenderableCache()
return <div id="cache-content">{`Cache value: ${value}`}</div>
}
async function nonPrerenderableCache() {
'use cache'
cacheLife({ expire: 300 - 1 }) // smaller than MIN_PRERENDERABLE_EXPIRE
await new Promise((resolve) => setTimeout(resolve))
return Date.now()
}
import { Suspense } from 'react'
import { cacheLife } from 'next/cache'
export default function Page() {
return (
<main>
<p id="page-content">Uses a cache that is excluded from shells</p>
<Suspense fallback={<p id="cache-loading">Loading cache...</p>}>
<CacheContent />
</Suspense>
</main>
)
}
async function CacheContent() {
const value = await nonShellCache()
return <div id="cache-content">{`Cache value: ${value}`}</div>
}
async function nonShellCache() {
'use cache'
cacheLife({ stale: 300 - 1 }) // smaller than MIN_SHELL_STALE
await new Promise((resolve) => setTimeout(resolve))
return Date.now()
}
...@@ -106,6 +106,28 @@ export default function Page() { ...@@ -106,6 +106,28 @@ export default function Page() {
Dynamic param two Dynamic param two
</LinkAccordion> </LinkAccordion>
</li> </li>
<li>
Excluded caches
<ul>
<li>
<LinkAccordion href="/excluded-caches/uses-non-shell-cache">
Uses a cache that is excluded from the shell due to short stale
</LinkAccordion>
</li>
<li>
<LinkAccordion href="/excluded-caches/uses-non-prefetchable-cache">
Uses a cache that is excluded from all prerenders due to short
stale
</LinkAccordion>
</li>
<li>
<LinkAccordion href="/excluded-caches/uses-non-prerenderable-cache">
Uses a cache that is excluded from static prerenders due to
short expire
</LinkAccordion>
</li>
</ul>
</li>
{/* The speculative-* routes are partial (non-eager), so their {/* The speculative-* routes are partial (non-eager), so their
links use prefetch={true} to opt into the Speculative phase — links use prefetch={true} to opt into the Speculative phase —
otherwise only their App Shell would be prefetched. */} otherwise only their App Shell would be prefetched. */}
......
...@@ -642,6 +642,96 @@ describe('static App Shell prefetch attempt', () => { ...@@ -642,6 +642,96 @@ describe('static App Shell prefetch attempt', () => {
]) ])
}) })
describe('excluded caches', () => {
it("uses a static shell when the page accesses a cache that's excluded from shells due to a short staletime", async () => {
// Caches with `stale < MIN_SHELL_STALE` are excluded from shells.
// They should not cause a page to use a runtime shell.
let page: Playwright.Page
const browser = await next.browser('/', {
beforePageLoad(p: Playwright.Page) {
page = p
},
})
const act = createRouterAct(page, { includeAppShellRequests: true })
await act(async () => {
await browser
.elementByCss(
'input[data-link-accordion="/excluded-caches/uses-non-shell-cache"]'
)
.click()
}, [
// The static request still includes the cache, because it's included
// in the static prerender.
{
includes: 'Cache value',
kind: 'static',
},
])
})
it("uses a static shell when the page accesses a cache that's not prefetchable due to a short staletime", async () => {
// Caches with `stale < MIN_PREFETCHABLE_STALE` are excluded from all prerenders.
// They should not cause a page to use a runtime shell.
let page: Playwright.Page
const browser = await next.browser('/', {
beforePageLoad(p: Playwright.Page) {
page = p
},
})
const act = createRouterAct(page, { includeAppShellRequests: true })
await act(async () => {
await browser
.elementByCss(
'input[data-link-accordion="/excluded-caches/uses-non-prefetchable-cache"]'
)
.click()
}, [
// We should use a static request.
{
includes: 'Uses a cache that is excluded from all prerenders',
kind: 'static',
},
// The static prerender should not include the cache.
{
includes: 'Cache value',
block: 'reject',
},
])
})
it("uses a runtime shell when the page accesses a cache that's excluded from static prerenders due to short expire", async () => {
// Caches with `expire < MIN_PRERENDERABLE_EXPIRE` are excluded from
// static prerenders, but included in runtime prerenders. If a page
// uses one, it should use a runtime shell and access the cache.
let page: Playwright.Page
const browser = await next.browser('/', {
beforePageLoad(p: Playwright.Page) {
page = p
},
})
const act = createRouterAct(page, { includeAppShellRequests: true })
await act(async () => {
await browser
.elementByCss(
'input[data-link-accordion="/excluded-caches/uses-non-prerenderable-cache"]'
)
.click()
}, [
// We should use a runtime shell, and the cache should be included.
{
includes: 'Cache value',
kind: 'runtime',
},
])
})
})
it('reuses the static App Shell across different param values of a dynamic route', async () => { it('reuses the static App Shell across different param values of a dynamic route', async () => {
let page: Playwright.Page let page: Playwright.Page
const browser = await next.browser('/', { const browser = await next.browser('/', {
......
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