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
238a8ac8
Unverified
Commit
238a8ac8
authored
May 15, 2025
by
Hendrik Liebau
Committed by
GitHub
May 15, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Partial Fallback Prerendering Route Shells (#69282)" (#79258)
parent
21e44116
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
52 additions
and
237 deletions
+52
-237
base-server.ts
packages/next/src/server/base-server.ts
+0
-47
image-optimizer.ts
packages/next/src/server/image-optimizer.ts
+0
-1
index.ts
packages/next/src/server/lib/incremental-cache/index.ts
+0
-3
next-server.ts
packages/next/src/server/next-server.ts
+0
-1
types.ts
packages/next/src/server/response-cache/types.ts
+0
-2
utils.ts
packages/next/src/server/response-cache/utils.ts
+0
-1
app-static.test.ts
test/e2e/app-dir/app-static/app-static.test.ts
+9
-25
page.js
...dir/next-after-app-deploy/app/timestamp/key/[key]/page.js
+5
-1
ppr-full.test.ts
test/e2e/app-dir/ppr-full/ppr-full.test.ts
+36
-154
ppr-incremental.test.ts
test/e2e/app-dir/ppr-incremental/ppr-incremental.test.ts
+2
-2
No files found.
packages/next/src/server/base-server.ts
View file @
238a8ac8
...
@@ -168,7 +168,6 @@ import { RouteKind } from './route-kind'
...
@@ -168,7 +168,6 @@ import { RouteKind } from './route-kind'
import
type
{
RouteModule
}
from
'./route-modules/route-module'
import
type
{
RouteModule
}
from
'./route-modules/route-module'
import
{
FallbackMode
,
parseFallbackField
}
from
'../lib/fallback'
import
{
FallbackMode
,
parseFallbackField
}
from
'../lib/fallback'
import
{
toResponseCacheEntry
}
from
'./response-cache/utils'
import
{
toResponseCacheEntry
}
from
'./response-cache/utils'
import
{
scheduleOnNextTick
}
from
'../lib/scheduler'
import
{
SegmentPrefixRSCPathnameNormalizer
}
from
'./normalizers/request/segment-prefix-rsc'
import
{
SegmentPrefixRSCPathnameNormalizer
}
from
'./normalizers/request/segment-prefix-rsc'
import
{
import
{
shouldServeStreamingMetadata
,
shouldServeStreamingMetadata
,
...
@@ -2674,7 +2673,6 @@ export default abstract class Server<
...
@@ -2674,7 +2673,6 @@ export default abstract class Server<
headers
,
headers
,
},
},
cacheControl
:
{
revalidate
,
expire
},
cacheControl
:
{
revalidate
,
expire
},
isFallback
:
false
,
}
}
return
cacheEntry
return
cacheEntry
...
@@ -2881,7 +2879,6 @@ export default abstract class Server<
...
@@ -2881,7 +2879,6 @@ export default abstract class Server<
return
{
return
{
value
:
null
,
value
:
null
,
cacheControl
,
cacheControl
,
isFallback
:
false
,
}
satisfies
ResponseCacheEntry
}
satisfies
ResponseCacheEntry
}
}
...
@@ -2893,7 +2890,6 @@ export default abstract class Server<
...
@@ -2893,7 +2890,6 @@ export default abstract class Server<
props
:
metadata
.
pageData
??
metadata
.
flightData
,
props
:
metadata
.
pageData
??
metadata
.
flightData
,
}
satisfies
CachedRedirectValue
,
}
satisfies
CachedRedirectValue
,
cacheControl
,
cacheControl
,
isFallback
:
false
,
}
satisfies
ResponseCacheEntry
}
satisfies
ResponseCacheEntry
}
}
...
@@ -2915,7 +2911,6 @@ export default abstract class Server<
...
@@ -2915,7 +2911,6 @@ export default abstract class Server<
segmentData
:
metadata
.
segmentData
,
segmentData
:
metadata
.
segmentData
,
}
satisfies
CachedAppPageValue
,
}
satisfies
CachedAppPageValue
,
cacheControl
,
cacheControl
,
isFallback
:
!!
fallbackRouteParams
,
}
satisfies
ResponseCacheEntry
}
satisfies
ResponseCacheEntry
}
}
...
@@ -2928,7 +2923,6 @@ export default abstract class Server<
...
@@ -2928,7 +2923,6 @@ export default abstract class Server<
status
:
isAppPath
?
res
.
statusCode
:
undefined
,
status
:
isAppPath
?
res
.
statusCode
:
undefined
,
}
satisfies
CachedPageValue
,
}
satisfies
CachedPageValue
,
cacheControl
,
cacheControl
,
isFallback
:
pagesFallback
,
}
}
}
}
...
@@ -3155,7 +3149,6 @@ export default abstract class Server<
...
@@ -3155,7 +3149,6 @@ export default abstract class Server<
)
{
)
{
return
{
return
{
cacheControl
:
{
revalidate
:
1
,
expire
:
undefined
},
cacheControl
:
{
revalidate
:
1
,
expire
:
undefined
},
isFallback
:
false
,
value
:
{
value
:
{
kind
:
CachedRouteKind
.
PAGES
,
kind
:
CachedRouteKind
.
PAGES
,
html
:
RenderResult
.
fromStatic
(
''
),
html
:
RenderResult
.
fromStatic
(
''
),
...
@@ -3220,46 +3213,6 @@ export default abstract class Server<
...
@@ -3220,46 +3213,6 @@ export default abstract class Server<
return
null
return
null
}
}
// If we're not in minimal mode and the cache entry that was returned was a
// app page fallback, then we need to kick off the dynamic shell generation.
if
(
ssgCacheKey
&&
!
this
.
minimalMode
&&
isRoutePPREnabled
&&
cacheEntry
.
value
?.
kind
===
CachedRouteKind
.
APP_PAGE
&&
cacheEntry
.
isFallback
&&
!
isOnDemandRevalidate
&&
// When we're debugging the fallback shell, we don't want to regenerate
// the route shell.
!
isDebugFallbackShell
&&
process
.
env
.
DISABLE_ROUTE_SHELL_GENERATION
!==
'true'
)
{
scheduleOnNextTick
(
async
()
=>
{
try
{
await
this
.
responseCache
.
get
(
ssgCacheKey
,
()
=>
doRender
({
// We're an on-demand request, so we don't need to pass in the
// fallbackRouteParams.
fallbackRouteParams
:
null
,
pagesFallback
:
undefined
,
postponed
:
undefined
,
}),
{
routeKind
:
RouteKind
.
APP_PAGE
,
incrementalCache
,
isOnDemandRevalidate
:
true
,
isPrefetch
:
false
,
isRoutePPREnabled
:
true
,
}
)
}
catch
(
err
)
{
console
.
error
(
'Error occurred while rendering dynamic shell'
,
err
)
}
})
}
const
didPostpone
=
const
didPostpone
=
cacheEntry
.
value
?.
kind
===
CachedRouteKind
.
APP_PAGE
&&
cacheEntry
.
value
?.
kind
===
CachedRouteKind
.
APP_PAGE
&&
typeof
cacheEntry
.
value
.
postponed
===
'string'
typeof
cacheEntry
.
value
.
postponed
===
'string'
...
...
packages/next/src/server/image-optimizer.ts
View file @
238a8ac8
...
@@ -418,7 +418,6 @@ export class ImageOptimizerCache {
...
@@ -418,7 +418,6 @@ export class ImageOptimizerCache {
Date
.
now
(),
Date
.
now
(),
cacheControl
:
{
revalidate
:
maxAge
,
expire
:
undefined
},
cacheControl
:
{
revalidate
:
maxAge
,
expire
:
undefined
},
isStale
:
now
>
expireAt
,
isStale
:
now
>
expireAt
,
isFallback
:
false
,
}
}
}
}
}
catch
(
_
)
{
}
catch
(
_
)
{
...
...
packages/next/src/server/lib/incremental-cache/index.ts
View file @
238a8ac8
...
@@ -477,7 +477,6 @@ export class IncrementalCache implements IncrementalCacheType {
...
@@ -477,7 +477,6 @@ export class IncrementalCache implements IncrementalCacheType {
}
}
let entry: IncrementalResponseCacheEntry | null = null
let entry: IncrementalResponseCacheEntry | null = null
const { isFallback } = ctx
const cacheControl = this.cacheControls.get(toRoute(cacheKey))
const cacheControl = this.cacheControls.get(toRoute(cacheKey))
let isStale: boolean | -1 | undefined
let isStale: boolean | -1 | undefined
...
@@ -506,7 +505,6 @@ export class IncrementalCache implements IncrementalCacheType {
...
@@ -506,7 +505,6 @@ export class IncrementalCache implements IncrementalCacheType {
cacheControl,
cacheControl,
revalidateAfter,
revalidateAfter,
value: cacheData.value,
value: cacheData.value,
isFallback,
}
}
}
}
...
@@ -524,7 +522,6 @@ export class IncrementalCache implements IncrementalCacheType {
...
@@ -524,7 +522,6 @@ export class IncrementalCache implements IncrementalCacheType {
value: null,
value: null,
cacheControl,
cacheControl,
revalidateAfter,
revalidateAfter,
isFallback,
}
}
this.set(cacheKey, entry.value, { ...ctx, cacheControl })
this.set(cacheKey, entry.value, { ...ctx, cacheControl })
}
}
...
...
packages/next/src/server/next-server.ts
View file @
238a8ac8
...
@@ -1049,7 +1049,6 @@ export default class NextNodeServer extends BaseServer<
...
@@ -1049,7 +1049,6 @@ export default class NextNodeServer extends BaseServer<
extension
:
getExtension
(
contentType
)
as
string
,
extension
:
getExtension
(
contentType
)
as
string
,
upstreamEtag
,
upstreamEtag
,
},
},
isFallback
:
false
,
cacheControl
:
{
revalidate
:
maxAge
,
expire
:
undefined
},
cacheControl
:
{
revalidate
:
maxAge
,
expire
:
undefined
},
}
}
},
},
...
...
packages/next/src/server/response-cache/types.ts
View file @
238a8ac8
...
@@ -142,7 +142,6 @@ export interface IncrementalResponseCacheEntry {
...
@@ -142,7 +142,6 @@ export interface IncrementalResponseCacheEntry {
*/
*/
isStale
?:
boolean
|
-
1
isStale
?:
boolean
|
-
1
isMiss
?:
boolean
isMiss
?:
boolean
isFallback
:
boolean
|
undefined
value
:
Exclude
<
IncrementalCacheValue
,
CachedFetchValue
>
|
null
value
:
Exclude
<
IncrementalCacheValue
,
CachedFetchValue
>
|
null
}
}
...
@@ -178,7 +177,6 @@ export type ResponseCacheEntry = {
...
@@ -178,7 +177,6 @@ export type ResponseCacheEntry = {
value
:
ResponseCacheValue
|
null
value
:
ResponseCacheValue
|
null
isStale
?:
boolean
|
-
1
isStale
?:
boolean
|
-
1
isMiss
?:
boolean
isMiss
?:
boolean
isFallback
:
boolean
|
undefined
}
}
/**
/**
...
...
packages/next/src/server/response-cache/utils.ts
View file @
238a8ac8
...
@@ -47,7 +47,6 @@ export async function toResponseCacheEntry(
...
@@ -47,7 +47,6 @@ export async function toResponseCacheEntry(
isMiss
:
response
.
isMiss
,
isMiss
:
response
.
isMiss
,
isStale
:
response
.
isStale
,
isStale
:
response
.
isStale
,
cacheControl
:
response
.
cacheControl
,
cacheControl
:
response
.
cacheControl
,
isFallback
:
response
.
isFallback
,
value
:
value
:
response
.
value
?.
kind
===
CachedRouteKind
.
PAGES
response
.
value
?.
kind
===
CachedRouteKind
.
PAGES
?
({
?
({
...
...
test/e2e/app-dir/app-static/app-static.test.ts
View file @
238a8ac8
...
@@ -2818,9 +2818,7 @@ describe('app-dir static/dynamic handling', () => {
...
@@ -2818,9 +2818,7 @@ describe('app-dir static/dynamic handling', () => {
for
(
let
i
=
0
;
i
<
5
;
i
++
)
{
for
(
let
i
=
0
;
i
<
5
;
i
++
)
{
const
res
=
await
next
.
fetch
(
'/articles/non-existent'
)
const
res
=
await
next
.
fetch
(
'/articles/non-existent'
)
// Only the first request should be a 200 while using PPR. When the route
if
(
process
.
env
.
__NEXT_EXPERIMENTAL_PPR
&&
!
isNextDev
)
{
// shell is generated, the status code will switch to 404.
if
(
process
.
env
.
__NEXT_EXPERIMENTAL_PPR
&&
!
isNextDev
&&
i
===
0
)
{
expect
(
res
.
status
).
toBe
(
200
)
expect
(
res
.
status
).
toBe
(
200
)
}
else
{
}
else
{
expect
(
res
.
status
).
toBe
(
404
)
expect
(
res
.
status
).
toBe
(
404
)
...
@@ -3789,34 +3787,20 @@ describe('app-dir static/dynamic handling', () => {
...
@@ -3789,34 +3787,20 @@ describe('app-dir static/dynamic handling', () => {
expect
(
res
.
status
).
toBe
(
200
)
expect
(
res
.
status
).
toBe
(
200
)
const
html
=
await
res
.
text
()
const
html
=
await
res
.
text
()
le
t
$
=
cheerio
.
load
(
html
)
cons
t
$
=
cheerio
.
load
(
html
)
expect
(
JSON
.
parse
(
$
(
'#params'
).
text
())).
toEqual
({
slug
:
'random'
})
expect
(
JSON
.
parse
(
$
(
'#params'
).
text
())).
toEqual
({
slug
:
'random'
})
expect
(
JSON
.
parse
(
$
(
'#headers'
).
text
())).
toEqual
([])
expect
(
JSON
.
parse
(
$
(
'#headers'
).
text
())).
toEqual
([])
expect
(
JSON
.
parse
(
$
(
'#cookies'
).
text
())).
toEqual
([])
expect
(
JSON
.
parse
(
$
(
'#cookies'
).
text
())).
toEqual
([])
const
firstTime
=
$
(
'#now'
).
text
()
if
(
!
(
global
as
any
).
isNextDev
)
{
if
(
!
(
global
as
any
).
isNextDev
)
{
if
(
process
.
env
.
__NEXT_EXPERIMENTAL_PPR
)
{
const
res2
=
await
next
.
fetch
(
'/force-static/random'
)
// When PPR is enabled, we first encounter the fallback shell. We do
expect
(
res2
.
status
).
toBe
(
200
)
// expect though that the page does not change after the dynamic shell
// has been finalized.
const
$2
=
cheerio
.
load
(
await
res2
.
text
())
await
retry
(
async
()
=>
{
expect
(
firstTime
).
toBe
(
$2
(
'#now'
).
text
())
$
=
await
next
.
render$
(
'/force-static/random'
)
const
first
=
$
(
'#now'
).
text
()
$
=
await
next
.
render$
(
'/force-static/random'
)
// The page should not change after the dynamic shell has been
// finalized.
expect
(
$
(
'#now'
).
text
()).
toBe
(
first
)
})
}
else
{
const
first
=
$
(
'#now'
).
text
()
$
=
await
next
.
render$
(
'/force-static/random'
)
expect
(
$
(
'#now'
).
text
()).
toBe
(
first
)
}
}
}
})
})
}
}
...
...
test/e2e/app-dir/next-after-app-deploy/app/timestamp/key/[key]/page.js
View file @
238a8ac8
...
@@ -5,7 +5,11 @@ export const revalidate = 3600 // arbitrarily long, just so that it doesn't happ
...
@@ -5,7 +5,11 @@ export const revalidate = 3600 // arbitrarily long, just so that it doesn't happ
export
const
dynamicParams
=
true
export
const
dynamicParams
=
true
export
async
function
generateStaticParams
()
{
export
async
function
generateStaticParams
()
{
return
[]
return
[
'nodejs'
,
'edge'
].
flatMap
((
runtime
)
=>
[
'dynamic-page'
,
'middleware'
,
'route'
,
'server-action'
].
map
((
page
)
=>
({
key
:
`/
${
runtime
}
/
${
page
}
`
,
}))
)
}
}
export
default
async
function
Page
({
params
})
{
export
default
async
function
Page
({
params
})
{
...
...
test/e2e/app-dir/ppr-full/ppr-full.test.ts
View file @
238a8ac8
...
@@ -353,176 +353,58 @@ describe('ppr-full', () => {
...
@@ -353,176 +353,58 @@ describe('ppr-full', () => {
expect
(
$
(
'[data-agent]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
expect
(
$
(
'[data-agent]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
})
})
if
(
isNextDeploy
)
{
it
(
'should render the fallback shell every time'
,
async
()
=>
{
it
(
'should render the fallback shell every time'
,
async
()
=>
{
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
const
pathname
=
`/fallback/dynamic/params/on-second-visit-
${
random
}
`
const
pathname
=
`/fallback/dynamic/params/on-second-visit-
${
random
}
`
let
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
expect
(
$
(
'[data-agent]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
expect
(
$
(
'[data-agent]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
}
})
it
(
'should render the fallback shell even if the page is static'
,
async
()
=>
{
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
const
pathname
=
`/fallback/params/on-second-visit-
${
random
}
`
// Expect that the slug had to be resumed.
let
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
}
})
it
(
'will not revalidate the fallback shell'
,
async
()
=>
{
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
const
pathname
=
`/fallback/dynamic/params/revalidate-
${
random
}
`
let
$
=
await
next
.
render$
(
pathname
)
const
fallbackID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
// Now let's revalidate the page.
let
$
=
await
next
.
render$
(
pathname
)
await
next
.
fetch
(
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
`/api/revalidate?pathname=
${
encodeURIComponent
(
pathname
)}
`
expect
(
$
(
'[data-agent]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
)
// We expect to get the fallback shell again.
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
$
=
await
next
.
render$
(
pathname
)
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'[data-layout]'
).
data
(
'layout'
)).
toBe
(
fallbackID
)
// Let's wait for the page to be revalidated.
await
retry
(
async
()
=>
{
$
=
await
next
.
render$
(
pathname
)
const
newDynamicID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
expect
(
newDynamicID
).
toBe
(
fallbackID
)
})
})
}
else
{
it
(
'should render the route shell on the second visit'
,
async
()
=>
{
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
const
pathname
=
`/fallback/dynamic/params/on-second-visit-
${
random
}
`
let
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
expect
(
$
(
'[data-agent]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
expect
(
$
(
'[data-agent]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
}
})
await
retry
(
async
()
=>
{
it
(
'should render the fallback shell even if the page is static'
,
async
()
=>
{
$
=
await
next
.
render$
(
pathname
)
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
0
)
const
pathname
=
`/fallback/params/on-second-visit-
${
random
}
`
expect
(
$
(
'[data-agent]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
})
})
it
(
'should render the dynamic shell as static if the page is static'
,
async
()
=>
{
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
const
pathname
=
`/fallback/params/on-second-visit-
${
random
}
`
// Expect that the slug had to be resumed.
let
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
// The slug didn't have to be resumed, and it should all be static.
await
retry
(
async
()
=>
{
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
0
)
const
{
timings
:
{
streamFirstChunk
,
start
,
streamEnd
},
chunks
,
}
=
await
measurePPRTimings
(
async
()
=>
{
const
res
=
await
next
.
fetch
(
pathname
)
expect
(
res
.
status
).
toBe
(
200
)
expect
(
res
.
headers
.
get
(
'x-nextjs-cache'
)).
toBe
(
'HIT'
)
return
res
.
body
},
1000
)
expect
(
chunks
.
dynamic
).
toBe
(
''
)
expect
(
streamFirstChunk
-
start
).
toBeLessThan
(
500
)
expect
(
streamEnd
-
start
).
toBeLessThan
(
500
)
})
})
it
(
'will only revalidate the page'
,
async
()
=>
{
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
const
pathname
=
`/fallback/dynamic/params/revalidate-
${
random
}
`
let
$
=
await
next
.
render$
(
pathname
)
const
fallbackID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
let
dynamicID
:
string
await
retry
(
async
()
=>
{
$
=
await
next
.
render$
(
pathname
)
dynamicID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
// These should be different,
expect
(
dynamicID
).
not
.
toBe
(
fallbackID
)
})
// Now let's revalidate the page.
// Expect that the slug had to be resumed.
await
next
.
fetch
(
let
$
=
await
next
.
render$
(
pathname
)
`/api/revalidate?pathname=
${
encodeURIComponent
(
pathname
)}
`
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
)
// We expect to get the fallback shell again.
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
$
=
await
next
.
render$
(
pathname
)
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'[data-layout]'
).
data
(
'layout'
)).
toBe
(
fallbackID
)
expect
(
$
(
'[data-slug]'
).
closest
(
'[hidden]'
).
length
).
toBe
(
1
)
}
// Let's wait for the page to be revalidated.
})
await
retry
(
async
()
=>
{
$
=
await
next
.
render$
(
pathname
)
const
newDynamicID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
expect
(
newDynamicID
).
not
.
toBe
(
dynamicID
)
})
})
it
(
'will revalidate the page and fallback shell'
,
async
()
=>
{
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
const
pathname
=
`/fallback/dynamic/params/revalidate-
${
random
}
`
let
$
=
await
next
.
render$
(
pathname
)
it
(
'will not revalidate the fallback shell'
,
async
()
=>
{
const
fallbackID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
const
random
=
Math
.
random
().
toString
(
16
).
slice
(
2
)
const
pathname
=
`/fallback/dynamic/params/revalidate-
${
random
}
`
let
dynamicID
:
string
let
$
=
await
next
.
render$
(
pathname
)
await
retry
(
async
()
=>
{
const
fallbackID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
$
=
await
next
.
render$
(
pathname
)
dynamicID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
// These should be different,
// Now let's revalidate the page.
expect
(
dynamicID
).
not
.
toBe
(
fallbackID
)
await
next
.
fetch
(
})
`/api/revalidate?pathname=
${
encodeURIComponent
(
pathname
)}
`
)
// Now let's revalidate the page.
// We expect to get the fallback shell again.
await
next
.
fetch
(
$
=
await
next
.
render$
(
pathname
)
`/api/revalidate?pathname=
${
encodeURIComponent
(
pathname
)}
`
expect
(
$
(
'[data-layout]'
).
data
(
'layout'
)).
toBe
(
fallbackID
)
)
// We expect to get the fallback shell.
// Let's wait for the page to be revalidated.
await
retry
(
async
()
=>
{
$
=
await
next
.
render$
(
pathname
)
$
=
await
next
.
render$
(
pathname
)
const
newDynamicID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
// When deployed to Vercel, it will serve a stale version of the dynamic shell
expect
(
newDynamicID
).
toBe
(
fallbackID
)
// Whereas with `next start` it will serve the fallback shell
expect
(
$
(
'[data-layout]'
).
data
(
'layout'
)).
toBe
(
fallbackID
)
// Let's wait for the page to be revalidated.
let
revalidatedDynamicID
:
string
await
retry
(
async
()
=>
{
$
=
await
next
.
render$
(
pathname
)
revalidatedDynamicID
=
$
(
'[data-layout]'
).
data
(
'layout'
)
as
string
expect
(
revalidatedDynamicID
).
not
.
toBe
(
dynamicID
)
expect
(
revalidatedDynamicID
).
not
.
toBe
(
fallbackID
)
})
})
})
}
}
)
/**
/**
* This test is really here to just to force the the suite to have the expected route
* This test is really here to just to force the the suite to have the expected route
...
...
test/e2e/app-dir/ppr-incremental/ppr-incremental.test.ts
View file @
238a8ac8
...
@@ -144,7 +144,7 @@ describe('ppr-incremental', () => {
...
@@ -144,7 +144,7 @@ describe('ppr-incremental', () => {
it
.
each
(
pathnames
)(
'%s'
,
async
(
pathname
)
=>
{
it
.
each
(
pathnames
)(
'%s'
,
async
(
pathname
)
=>
{
const
$
=
await
next
.
render$
(
pathname
)
const
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'#dynamic'
)).
toHaveLength
(
1
)
expect
(
$
(
'#dynamic'
)).
toHaveLength
(
1
)
expect
(
$
(
'#dynamic'
).
closes
t
(
'[hidden]'
)).
toHaveLength
(
0
)
expect
(
$
(
'#dynamic'
).
paren
t
(
'[hidden]'
)).
toHaveLength
(
0
)
})
})
})
})
}
}
...
@@ -196,7 +196,7 @@ describe('ppr-incremental', () => {
...
@@ -196,7 +196,7 @@ describe('ppr-incremental', () => {
it
.
each
(
pathnames
)(
'%s'
,
async
(
pathname
)
=>
{
it
.
each
(
pathnames
)(
'%s'
,
async
(
pathname
)
=>
{
const
$
=
await
next
.
render$
(
pathname
)
const
$
=
await
next
.
render$
(
pathname
)
expect
(
$
(
'#dynamic'
)).
toHaveLength
(
1
)
expect
(
$
(
'#dynamic'
)).
toHaveLength
(
1
)
expect
(
$
(
'#dynamic'
).
closes
t
(
'[hidden]'
)).
toHaveLength
(
1
)
expect
(
$
(
'#dynamic'
).
paren
t
(
'[hidden]'
)).
toHaveLength
(
1
)
})
})
})
})
}
}
...
...
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