Skip to content

Commit 58a0c3d

Browse files
authored
[test] Park the blocking-fallback segment on a withheld param (#95300)
The `blocking-fallback/[lang]/[scope]` fixture's deeper page previously rendered a static title and gated its only dynamic work on a `cookies( ` read. Under instant() the committed app shell is allowed to read reque t cookies without blocking, which is exactly what the cookie assertions n this suite rely on, so a segment gated only on cookies renders into th shell and its title commits while the lock is held. Under CPU load thi surfaced as a flaky leak of `blocking-scope-title` during the parke navigation, and instrumenting the lock's read path confirmed the cause the test failed precisely when the app-shell (RuntimeShell) entry committe the deeper segment and passed when the speculative static prefetch (PPR) e try committed, a commit-order race between the two prefetch responses This change makes `ScopePage` await `params` before rendering anything. Because `scope` is an uncovered fallback param (the route has no `generateStaticParams`), awaiting it suspends the whole segment during the app-shell prerender and keeps both the title and the cookie value out of the committed shell regardless of which prefetch wins. The segment streams in only after the lock releases, when the real dynamic render resolves `params`. The underlying app-shell-versus-speculative-prefetch race is a known, likely temporary limitation; the `cookies in the instant shell` describe block documents the related case and the planned fix of opting cookie-reading routes into partial or runtime prefetching. The test comment is updated to describe this param-gated parking instead of the previous cookie-based description. --- <sub>Stack created with <a href="GitHub">https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="Give" rel="nofollow">https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
1 parent 64fbcb6 commit 58a0c3d

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

‎test/e2e/app-dir/instant-navigation-testing-api/fixtures/default/app/blocking-fallback/[lang]/[scope]/page.tsx‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
import { cookies } from 'next/headers'
22

3-
// The deeper, blocking segment of the fallback route: reads request-time
4-
// `cookies()` and has no <Suspense> of its own, so it has no static shell.
5-
// Under instant() the navigation here must stay parked on the committed parent;
6-
// the cookie value must not commit while the lock is held.
7-
export default function ScopePage() {
3+
// The deeper, blocking segment of the fallback route: awaits the uncovered
4+
// `scope` param and reads request-time `cookies()`, and has no <Suspense> of
5+
// its own, so it has no static shell. Under instant() the navigation here must
6+
// stay parked on the committed parent; neither the title nor the cookie value
7+
// may commit while the lock is held.
8+
export default async function ScopePage({
9+
params,
10+
}: {
11+
params: Promise<{ lang: string; scope: string }>
12+
}) {
13+
// Await the uncovered `scope` fallback param to keep this segment parked
14+
// under instant(). The app shell is allowed to read `cookies()` without
15+
// blocking, so gating only on cookies would make parking depend on a race:
16+
// the title leaks when the cookie-bearing app-shell prefetch commits this
17+
// segment, but stays hidden when the empty static speculative prefetch
18+
// commits first. Awaiting the withheld param removes the title from both
19+
// prefetches, so it stays parked until the lock releases no matter which one
20+
// wins. This app-shell-versus-speculative-prefetch race is a known, likely
21+
// temporary limitation; see the note on the `cookies in the instant shell`
22+
// describe block for the related case and the planned fix.
23+
await params
24+
825
return (
926
<div>
1027
<h1 data-testid="blocking-scope-title">Scope</h1>

‎test/e2e/app-dir/instant-navigation-testing-api/instant-navigation-testing-api.test.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,13 @@ describe('instant-navigation-testing-api', () => {
136136
// Navigate deeper under the lock. Loading `/blocking-fallback/en` commits the
137137
// parent layout (which owns the only <Suspense> boundary) and the landing
138138
// page. `/blocking-fallback/en/s1` is a fallback route (`[scope]` has no
139-
// generateStaticParams) whose deeper page blocks on `cookies()`. Navigating
140-
// into it must stay parked: the committed parent and landing page stay on
141-
// screen, the deeper page and its cookie value must not commit while the lock
142-
// is held, and they stream in only after release.
139+
// generateStaticParams) whose deeper page awaits the uncovered `scope` param
140+
// and reads `cookies()`. Awaiting the withheld param is what keeps the
141+
// segment out of the app shell (the app shell is allowed to read cookies, so
142+
// a cookie read alone would not park it). Navigating into it must stay
143+
// parked: the committed parent and landing page stay on screen, the deeper
144+
// page (its title and its cookie value) must not commit while the lock is
145+
// held, and they stream in only after release.
143146
it('keeps the committed layout and defers a deeper blocking segment under instant()', async () => {
144147
const page = await openPage(next, '/blocking-fallback/en', {
145148
cookies: [{ name: 'testCookie', value: 'hello' }],

0 commit comments

Comments
 (0)