Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
adf7540e
Unverified
Commit
adf7540e
authored
Jun 14, 2026
by
Josh Story
Committed by
GitHub
Jun 14, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Avoid a premature Suspense fallback flash in the streaming dev render…"
This reverts commit
66496a4c
.
parent
573bb7f6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
114 additions
and
263 deletions
+114
-263
fetch-server-response.ts
...client/components/router-reducer/fetch-server-response.ts
+0
-10
ppr-navigations.ts
...t/src/client/components/router-reducer/ppr-navigations.ts
+6
-30
navigation.ts
...es/next/src/client/components/segment-cache/navigation.ts
+0
-15
app-render.tsx
packages/next/src/server/app-render/app-render.tsx
+87
-149
app-router-types.ts
packages/next/src/shared/lib/app-router-types.ts
+0
-24
cache-components-dev-streaming.test.ts
...ents-dev-streaming/cache-components-dev-streaming.test.ts
+21
-35
No files found.
packages/next/src/client/components/router-reducer/fetch-server-response.ts
View file @
adf7540e
...
@@ -89,15 +89,6 @@ type SpaFetchServerResponseResult = {
...
@@ -89,15 +89,6 @@ type SpaFetchServerResponseResult = {
runtimePrefetchStream
:
ReadableStream
<
Uint8Array
>
|
null
runtimePrefetchStream
:
ReadableStream
<
Uint8Array
>
|
null
responseHeaders
:
Headers
responseHeaders
:
Headers
debugInfo
:
Array
<
any
>
|
null
debugInfo
:
Array
<
any
>
|
null
/**
* Dev only: resolves once the server has flushed the shell-stage content to
* the stream (or earlier, on a cache miss). The navigation defers revealing
* the response (resolving its deferred RSCs) until this settles, so React
* doesn't render a boundary's children before their row has been decoded and
* commit a premature Suspense fallback. `null` outside the streaming dev
* render.
*/
revealAfter
:
Promise
<
void
>
|
null
}
}
type
MpaFetchServerResponseResult
=
string
type
MpaFetchServerResponseResult
=
string
...
@@ -310,7 +301,6 @@ export async function fetchServerResponse(
...
@@ -310,7 +301,6 @@ export async function fetchServerResponse(
runtimePrefetchStream
:
flightResponse
.
p
??
null
,
runtimePrefetchStream
:
flightResponse
.
p
??
null
,
responseHeaders
:
res
.
headers
,
responseHeaders
:
res
.
headers
,
debugInfo
:
flightResponsePromise
.
_debugInfo
??
null
,
debugInfo
:
flightResponsePromise
.
_debugInfo
??
null
,
revealAfter
:
flightResponse
.
_revealAfter
??
null
,
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
// If the fetch rejected due to a network error, wait for connectivity
// If the fetch rejected due to a network error, wait for connectivity
...
...
packages/next/src/client/components/router-reducer/ppr-navigations.ts
View file @
adf7540e
...
@@ -1802,8 +1802,7 @@ async function fetchMissingDynamicData(
...
@@ -1802,8 +1802,7 @@ async function fetchMissingDynamicData(
seed
.
data
,
seed
.
data
,
seed
.
head
,
seed
.
head
,
dynamicStaleAt
,
dynamicStaleAt
,
result
.
debugInfo
,
result
.
debugInfo
result
.
revealAfter
)
)
return
{
return
{
...
@@ -1831,18 +1830,11 @@ function writeDynamicDataIntoNavigationTask(
...
@@ -1831,18 +1830,11 @@ function writeDynamicDataIntoNavigationTask(
dynamicData
:
CacheNodeSeedData
|
null
,
dynamicData
:
CacheNodeSeedData
|
null
,
dynamicHead
:
HeadData
,
dynamicHead
:
HeadData
,
dynamicStaleAt
:
number
,
dynamicStaleAt
:
number
,
debugInfo
:
Array
<
any
>
|
null
,
debugInfo
:
Array
<
any
>
|
null
revealAfter
:
Promise
<
void
>
|
null
):
boolean
{
):
boolean
{
if
(
task
.
status
===
NavigationTaskStatus
.
Pending
&&
dynamicData
!==
null
)
{
if
(
task
.
status
===
NavigationTaskStatus
.
Pending
&&
dynamicData
!==
null
)
{
task
.
status
=
NavigationTaskStatus
.
Fulfilled
task
.
status
=
NavigationTaskStatus
.
Fulfilled
finishPendingCacheNode
(
finishPendingCacheNode
(
task
.
node
,
dynamicData
,
dynamicHead
,
debugInfo
)
task
.
node
,
dynamicData
,
dynamicHead
,
debugInfo
,
revealAfter
)
// Update the BFCache entry's staleAt for this segment with the value
// Update the BFCache entry's staleAt for this segment with the value
// from the dynamic response. This applies the per-page
// from the dynamic response. This applies the per-page
...
@@ -1901,8 +1893,7 @@ function writeDynamicDataIntoNavigationTask(
...
@@ -1901,8 +1893,7 @@ function writeDynamicDataIntoNavigationTask(
dynamicDataChild
,
dynamicDataChild
,
dynamicHead
,
dynamicHead
,
dynamicStaleAt
,
dynamicStaleAt
,
debugInfo
,
debugInfo
revealAfter
)
)
if
(
childDidReceiveUnknownParallelRoute
)
{
if
(
childDidReceiveUnknownParallelRoute
)
{
didReceiveUnknownParallelRoute
=
true
didReceiveUnknownParallelRoute
=
true
...
@@ -1925,8 +1916,7 @@ function finishPendingCacheNode(
...
@@ -1925,8 +1916,7 @@ function finishPendingCacheNode(
cacheNode
:
CacheNode
,
cacheNode
:
CacheNode
,
dynamicData
:
CacheNodeSeedData
,
dynamicData
:
CacheNodeSeedData
,
dynamicHead
:
HeadData
,
dynamicHead
:
HeadData
,
debugInfo
:
Array
<
any
>
|
null
,
debugInfo
:
Array
<
any
>
|
null
revealAfter
:
Promise
<
void
>
|
null
):
void
{
):
void
{
// Writes a dynamic response into an existing Cache Node tree. This does _not_
// Writes a dynamic response into an existing Cache Node tree. This does _not_
// create a new tree, it updates the existing tree in-place. So it must follow
// create a new tree, it updates the existing tree in-place. So it must follow
...
@@ -1959,21 +1949,7 @@ function finishPendingCacheNode(
...
@@ -1959,21 +1949,7 @@ function finishPendingCacheNode(
// This is a deferred RSC promise. We can fulfill it with the data we just
// This is a deferred RSC promise. We can fulfill it with the data we just
// received from the server. If it was already resolved by a different
// received from the server. If it was already resolved by a different
// navigation, then this does nothing because we can't overwrite data.
// navigation, then this does nothing because we can't overwrite data.
//
// In the streaming dev render, defer the fill until `revealAfter` settles,
// so React doesn't render the boundary's children before their row has been
// decoded (otherwise it suspends on the still-pending children and commits
// a premature fallback). Outside that render `revealAfter` is null and we
// resolve immediately.
if
(
revealAfter
!==
null
)
{
const
resolveRsc
=
()
=>
rsc
.
resolve
(
dynamicSegmentData
,
debugInfo
)
// Use the same callback for both outcomes: we don't expect `revealAfter`
// to reject, but if it ever did (e.g. a connection drop mid-stream) we'd
// still want to resolve the RSC.
revealAfter
.
then
(
resolveRsc
,
resolveRsc
)
}
else
{
rsc
.
resolve
(
dynamicSegmentData
,
debugInfo
)
rsc
.
resolve
(
dynamicSegmentData
,
debugInfo
)
}
}
else
{
}
else
{
// This is not a deferred RSC promise, nor is it empty, so it must have
// This is not a deferred RSC promise, nor is it empty, so it must have
// been populated by a different navigation. We must not overwrite it.
// been populated by a different navigation. We must not overwrite it.
...
...
packages/next/src/client/components/segment-cache/navigation.ts
View file @
adf7540e
...
@@ -578,21 +578,6 @@ async function navigateToUnknownRoute(
...
@@ -578,21 +578,6 @@ async function navigateToUnknownRoute(
}
}
}
}
// In the streaming dev render, this single response's seed content may still
// be streaming when we build the tree below. An unknown-route navigation
// places that content inline (it has no prior cache entry, so the server
// sends a full seed rather than the dynamic-only delta a known route gets),
// and that inline content is not gated like a known route's deferred RSCs. So
// React could read a still-pending chunk and flash a Suspense fallback
// (wanted on a cold cache, but not on a warm one). Wait for the shell to
// flush (`revealAfter`) first, so the inline seed content is decoded by the
// time React reads it, the same way the known-route path gates its deferred
// RSCs. `revealAfter` is null outside the streaming dev render. On a cache
// miss it resolves early, so the cold-cache fallback is still shown.
if
(
result
.
revealAfter
!==
null
)
{
await
result
.
revealAfter
}
return
navigateToKnownRoute
(
return
navigateToKnownRoute
(
now
,
now
,
state
,
state
,
...
...
packages/next/src/server/app-render/app-render.tsx
View file @
adf7540e
This diff is collapsed.
Click to expand it.
packages/next/src/shared/lib/app-router-types.ts
View file @
adf7540e
...
@@ -428,18 +428,6 @@ export type InitialRSCPayload = {
...
@@ -428,18 +428,6 @@ export type InitialRSCPayload = {
* staleness.
* staleness.
*/
*/
d
?:
number
d
?:
number
/**
* revealAfter (dev only). Resolves once the server has flushed the
* shell-stage content to the stream (static shell, or runtime-prefetchable
* shell for runtime-prefetch routes), or earlier on a cache miss. The client
* decodes this from the payload and defers resolving the response's deferred
* RSCs on it, so a boundary's children aren't revealed before their row has
* been decoded (which would flush a premature Suspense fallback). Its
* resolution row follows the children's row in the payload, so the children
* are decoded by the time the client unblocks. The HTML render gates on the
* same signal server-side instead of reading this field.
*/
_revealAfter
?:
Promise
<
void
>
}
}
// Response from `createFromFetch` for normal rendering
// Response from `createFromFetch` for normal rendering
...
@@ -482,18 +470,6 @@ export type NavigationFlightResponse = {
...
@@ -482,18 +470,6 @@ export type NavigationFlightResponse = {
* staleness.
* staleness.
*/
*/
d
?:
number
d
?:
number
/**
* revealAfter (dev only). Resolves once the server has flushed the
* shell-stage content to the stream (static shell, or runtime-prefetchable
* shell for runtime-prefetch routes), or earlier on a cache miss. The client
* decodes this from the payload and defers resolving the response's deferred
* RSCs on it, so a boundary's children aren't revealed before their row has
* been decoded (which would flush a premature Suspense fallback). Its
* resolution row follows the children's row in the payload, so the children
* are decoded by the time the client unblocks. The HTML render gates on the
* same signal server-side instead of reading this field.
*/
_revealAfter
?:
Promise
<
void
>
}
}
// Response from `createFromFetch` for server actions. Action's flight data can be null
// Response from `createFromFetch` for server actions. Action's flight data can be null
...
...
test/development/app-dir/cache-components-dev-streaming/cache-components-dev-streaming.test.ts
View file @
adf7540e
...
@@ -62,7 +62,7 @@ describe('cache-components-dev-streaming', () => {
...
@@ -62,7 +62,7 @@ describe('cache-components-dev-streaming', () => {
//
//
// Use instant checks throughout: `elementByCss`/`elementById` also wait for
// Use instant checks throughout: `elementByCss`/`elementById` also wait for
// the page "load" event, which (with `waitUntil: 'commit'`) only fires once
// the page "load" event, which (with `waitUntil: 'commit'`) only fires once
// the slow cache has filled
, which
would advance past the very window this
// the slow cache has filled
— that
would advance past the very window this
// test inspects.
// test inspects.
await
retry
(
async
()
=>
{
await
retry
(
async
()
=>
{
expect
(
await
browser
.
elementByCssInstant
(
'#dynamic'
).
text
()).
toBe
(
expect
(
await
browser
.
elementByCssInstant
(
'#dynamic'
).
text
()).
toBe
(
...
@@ -136,10 +136,9 @@ describe('cache-components-dev-streaming', () => {
...
@@ -136,10 +136,9 @@ describe('cache-components-dev-streaming', () => {
})
})
it
(
'shows the private-cache fallback on a cold client navigation but not on a warm one'
,
async
()
=>
{
it
(
'shows the private-cache fallback on a cold client navigation but not on a warm one'
,
async
()
=>
{
// Uses a runtime-prefetch route, whose cached content belongs to the
// Uses a runtime-prefetch route, whose stream is held back until after the
// runtime shell stage. On a warm navigation the client defers revealing
// runtime stage, so a warm navigation reliably delivers the content with
// the response (via `_revealAfter`) until the server has flushed the shell,
// the shell and omits the fallback.
// so the content arrives with the shell and the fallback isn't shown.
const
browser
=
await
next
.
browser
(
'/'
)
const
browser
=
await
next
.
browser
(
'/'
)
// Cold navigation: the cache misses and fills in the background, so the
// Cold navigation: the cache misses and fills in the background, so the
...
@@ -150,26 +149,22 @@ describe('cache-components-dev-streaming', () => {
...
@@ -150,26 +149,22 @@ describe('cache-components-dev-streaming', () => {
expect
(
await
browser
.
elementByCss
(
'#private-fallback'
).
text
()).
toBe
(
expect
(
await
browser
.
elementByCss
(
'#private-fallback'
).
text
()).
toBe
(
'Loading...'
'Loading...'
)
)
expect
(
await
browser
.
elementByCss
(
'#private'
).
text
()).
toBeDateString
()
await
retry
(
async
()
=>
{
expect
(
await
browser
.
elementByCssInstant
(
'#private'
).
text
()
).
toBeDateString
()
})
// Wait for the background write to settle so the next navigation hits the
// Wait for the background write to settle so the next navigation hits the
// warm entry instead of racing a pending write.
// warm entry instead of racing a pending write.
await
waitFor
(
2000
)
await
waitFor
(
2000
)
// Hard-reload home so the first navigation below is a fresh, unknown-route
// nav. An unknown route has no prior cache entry, so the server sends the
// content inline in the seed (rather than the dynamic-only delta a known
// route gets), and that inline reveal is gated on `_revealAfter` too, so
// even this first nav delivers the content with the shell. Later iterations
// navigate via back()/forward, exercising the known-route deferred-RSC
// path.
await
browser
.
loadPage
(
new
URL
(
'/'
,
next
.
url
).
href
)
// Warm navigation: record whether the fallback ever enters the DOM during
// Warm navigation: record whether the fallback ever enters the DOM during
// the navigation, even briefly. It shouldn't, since the warm content is
// the navigation, even briefly. It shouldn't, since the warm content is
// delivered with the shell.
// delivered with the shell.
await
browser
.
loadPage
(
new
URL
(
'/'
,
next
.
url
).
href
)
await
browser
.
eval
(()
=>
{
await
browser
.
eval
(()
=>
{
;(
window
as
any
).
__privateFallbackSeen
=
0
;(
window
as
any
).
__privateFallbackSeen
=
false
new
MutationObserver
((
records
)
=>
{
new
MutationObserver
((
records
)
=>
{
records
.
forEach
((
record
)
=>
records
.
forEach
((
record
)
=>
record
.
addedNodes
.
forEach
((
node
)
=>
{
record
.
addedNodes
.
forEach
((
node
)
=>
{
...
@@ -178,33 +173,24 @@ describe('cache-components-dev-streaming', () => {
...
@@ -178,33 +173,24 @@ describe('cache-components-dev-streaming', () => {
(
node
.
id
===
'private-fallback'
||
(
node
.
id
===
'private-fallback'
||
node
.
querySelector
(
'#private-fallback'
))
node
.
querySelector
(
'#private-fallback'
))
)
{
)
{
;(
window
as
any
).
__privateFallbackSeen
+=
1
;(
window
as
any
).
__privateFallbackSeen
=
true
}
}
})
})
)
)
}).
observe
(
document
.
body
,
{
childList
:
true
,
subtree
:
true
})
}).
observe
(
document
.
body
,
{
childList
:
true
,
subtree
:
true
})
})
})
// Regression test for a rare client-side race the `_revealAfter` gate
// fixes. The Flight client decodes the response incrementally, so before
// the gate React Fiber could occasionally commit the fallback before the
// children's row was processed, even though the warm content is delivered
// with the shell. Deferring the reveal until `_revealAfter` settles means
// the children are decoded by the time React reads them, so the fallback no
// longer appears. The race was timing-dependent, so a single navigation
// would catch a regression only by luck; we repeat the warm navigation many
// times and assert the fallback never enters the DOM.
for
(
let
i
=
0
;
i
<
100
;
i
++
)
{
await
browser
await
browser
.
elementByCss
(
'a[href="/use-cache-private-runtime-prefetch"]'
)
.
elementByCss
(
'a[href="/use-cache-private-runtime-prefetch"]'
)
.
click
()
.
click
()
expect
(
await
browser
.
elementByCss
(
'#private'
).
text
()).
toBeDateString
()
await
retry
(
async
()
=>
{
await
browser
.
back
()
expect
(
}
await
browser
.
elementByCssInstant
(
'#private'
).
text
()
).
toBeDateString
()
})
expect
(
expect
(
await
browser
.
eval
(()
=>
(
window
as
any
).
__privateFallbackSeen
)
await
browser
.
eval
(()
=>
(
window
as
any
).
__privateFallbackSeen
)
).
toBe
(
0
)
).
toBe
(
false
)
})
})
// The following are smoke tests that Cache Components validation still
// The following are smoke tests that Cache Components validation still
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment