Skip to content

Commit 238a8ac

Browse files
authored
Revert "Partial Fallback Prerendering Route Shells (#69282)" (#79258)
1 parent 21e4411 commit 238a8ac

File tree

10 files changed

+52
-237
lines changed

10 files changed

+52
-237
lines changed

packages/next/src/server/base-server.ts

-47
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ import { RouteKind } from './route-kind'
168168
import type { RouteModule } from './route-modules/route-module'
169169
import { FallbackMode, parseFallbackField } from '../lib/fallback'
170170
import { toResponseCacheEntry } from './response-cache/utils'
171-
import { scheduleOnNextTick } from '../lib/scheduler'
172171
import { SegmentPrefixRSCPathnameNormalizer } from './normalizers/request/segment-prefix-rsc'
173172
import {
174173
shouldServeStreamingMetadata,
@@ -2674,7 +2673,6 @@ export default abstract class Server<
26742673
headers,
26752674
},
26762675
cacheControl: { revalidate, expire },
2677-
isFallback: false,
26782676
}
26792677

26802678
return cacheEntry
@@ -2881,7 +2879,6 @@ export default abstract class Server<
28812879
return {
28822880
value: null,
28832881
cacheControl,
2884-
isFallback: false,
28852882
} satisfies ResponseCacheEntry
28862883
}
28872884

@@ -2893,7 +2890,6 @@ export default abstract class Server<
28932890
props: metadata.pageData ?? metadata.flightData,
28942891
} satisfies CachedRedirectValue,
28952892
cacheControl,
2896-
isFallback: false,
28972893
} satisfies ResponseCacheEntry
28982894
}
28992895

@@ -2915,7 +2911,6 @@ export default abstract class Server<
29152911
segmentData: metadata.segmentData,
29162912
} satisfies CachedAppPageValue,
29172913
cacheControl,
2918-
isFallback: !!fallbackRouteParams,
29192914
} satisfies ResponseCacheEntry
29202915
}
29212916

@@ -2928,7 +2923,6 @@ export default abstract class Server<
29282923
status: isAppPath ? res.statusCode : undefined,
29292924
} satisfies CachedPageValue,
29302925
cacheControl,
2931-
isFallback: pagesFallback,
29322926
}
29332927
}
29342928

@@ -3155,7 +3149,6 @@ export default abstract class Server<
31553149
) {
31563150
return {
31573151
cacheControl: { revalidate: 1, expire: undefined },
3158-
isFallback: false,
31593152
value: {
31603153
kind: CachedRouteKind.PAGES,
31613154
html: RenderResult.fromStatic(''),
@@ -3220,46 +3213,6 @@ export default abstract class Server<
32203213
return null
32213214
}
32223215

3223-
// If we're not in minimal mode and the cache entry that was returned was a
3224-
// app page fallback, then we need to kick off the dynamic shell generation.
3225-
if (
3226-
ssgCacheKey &&
3227-
!this.minimalMode &&
3228-
isRoutePPREnabled &&
3229-
cacheEntry.value?.kind === CachedRouteKind.APP_PAGE &&
3230-
cacheEntry.isFallback &&
3231-
!isOnDemandRevalidate &&
3232-
// When we're debugging the fallback shell, we don't want to regenerate
3233-
// the route shell.
3234-
!isDebugFallbackShell &&
3235-
process.env.DISABLE_ROUTE_SHELL_GENERATION !== 'true'
3236-
) {
3237-
scheduleOnNextTick(async () => {
3238-
try {
3239-
await this.responseCache.get(
3240-
ssgCacheKey,
3241-
() =>
3242-
doRender({
3243-
// We're an on-demand request, so we don't need to pass in the
3244-
// fallbackRouteParams.
3245-
fallbackRouteParams: null,
3246-
pagesFallback: undefined,
3247-
postponed: undefined,
3248-
}),
3249-
{
3250-
routeKind: RouteKind.APP_PAGE,
3251-
incrementalCache,
3252-
isOnDemandRevalidate: true,
3253-
isPrefetch: false,
3254-
isRoutePPREnabled: true,
3255-
}
3256-
)
3257-
} catch (err) {
3258-
console.error('Error occurred while rendering dynamic shell', err)
3259-
}
3260-
})
3261-
}
3262-
32633216
const didPostpone =
32643217
cacheEntry.value?.kind === CachedRouteKind.APP_PAGE &&
32653218
typeof cacheEntry.value.postponed === 'string'

packages/next/src/server/image-optimizer.ts

-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ export class ImageOptimizerCache {
418418
Date.now(),
419419
cacheControl: { revalidate: maxAge, expire: undefined },
420420
isStale: now > expireAt,
421-
isFallback: false,
422421
}
423422
}
424423
} catch (_) {

packages/next/src/server/lib/incremental-cache/index.ts

-3
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ export class IncrementalCache implements IncrementalCacheType {
477477
}
478478

479479
let entry: IncrementalResponseCacheEntry | null = null
480-
const { isFallback } = ctx
481480
const cacheControl = this.cacheControls.get(toRoute(cacheKey))
482481

483482
let isStale: boolean | -1 | undefined
@@ -506,7 +505,6 @@ export class IncrementalCache implements IncrementalCacheType {
506505
cacheControl,
507506
revalidateAfter,
508507
value: cacheData.value,
509-
isFallback,
510508
}
511509
}
512510

@@ -524,7 +522,6 @@ export class IncrementalCache implements IncrementalCacheType {
524522
value: null,
525523
cacheControl,
526524
revalidateAfter,
527-
isFallback,
528525
}
529526
this.set(cacheKey, entry.value, { ...ctx, cacheControl })
530527
}

packages/next/src/server/next-server.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,6 @@ export default class NextNodeServer extends BaseServer<
10491049
extension: getExtension(contentType) as string,
10501050
upstreamEtag,
10511051
},
1052-
isFallback: false,
10531052
cacheControl: { revalidate: maxAge, expire: undefined },
10541053
}
10551054
},

packages/next/src/server/response-cache/types.ts

-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ export interface IncrementalResponseCacheEntry {
142142
*/
143143
isStale?: boolean | -1
144144
isMiss?: boolean
145-
isFallback: boolean | undefined
146145
value: Exclude<IncrementalCacheValue, CachedFetchValue> | null
147146
}
148147

@@ -178,7 +177,6 @@ export type ResponseCacheEntry = {
178177
value: ResponseCacheValue | null
179178
isStale?: boolean | -1
180179
isMiss?: boolean
181-
isFallback: boolean | undefined
182180
}
183181

184182
/**

packages/next/src/server/response-cache/utils.ts

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export async function toResponseCacheEntry(
4747
isMiss: response.isMiss,
4848
isStale: response.isStale,
4949
cacheControl: response.cacheControl,
50-
isFallback: response.isFallback,
5150
value:
5251
response.value?.kind === CachedRouteKind.PAGES
5352
? ({

test/e2e/app-dir/app-static/app-static.test.ts

+9-25
Original file line numberDiff line numberDiff line change
@@ -2818,9 +2818,7 @@ describe('app-dir static/dynamic handling', () => {
28182818
for (let i = 0; i < 5; i++) {
28192819
const res = await next.fetch('/articles/non-existent')
28202820

2821-
// Only the first request should be a 200 while using PPR. When the route
2822-
// shell is generated, the status code will switch to 404.
2823-
if (process.env.__NEXT_EXPERIMENTAL_PPR && !isNextDev && i === 0) {
2821+
if (process.env.__NEXT_EXPERIMENTAL_PPR && !isNextDev) {
28242822
expect(res.status).toBe(200)
28252823
} else {
28262824
expect(res.status).toBe(404)
@@ -3789,34 +3787,20 @@ describe('app-dir static/dynamic handling', () => {
37893787
expect(res.status).toBe(200)
37903788

37913789
const html = await res.text()
3792-
let $ = cheerio.load(html)
3790+
const $ = cheerio.load(html)
37933791

37943792
expect(JSON.parse($('#params').text())).toEqual({ slug: 'random' })
37953793
expect(JSON.parse($('#headers').text())).toEqual([])
37963794
expect(JSON.parse($('#cookies').text())).toEqual([])
37973795

3796+
const firstTime = $('#now').text()
3797+
37983798
if (!(global as any).isNextDev) {
3799-
if (process.env.__NEXT_EXPERIMENTAL_PPR) {
3800-
// When PPR is enabled, we first encounter the fallback shell. We do
3801-
// expect though that the page does not change after the dynamic shell
3802-
// has been finalized.
3803-
await retry(async () => {
3804-
$ = await next.render$('/force-static/random')
3805-
3806-
const first = $('#now').text()
3807-
3808-
$ = await next.render$('/force-static/random')
3809-
3810-
// The page should not change after the dynamic shell has been
3811-
// finalized.
3812-
expect($('#now').text()).toBe(first)
3813-
})
3814-
} else {
3815-
const first = $('#now').text()
3816-
3817-
$ = await next.render$('/force-static/random')
3818-
expect($('#now').text()).toBe(first)
3819-
}
3799+
const res2 = await next.fetch('/force-static/random')
3800+
expect(res2.status).toBe(200)
3801+
3802+
const $2 = cheerio.load(await res2.text())
3803+
expect(firstTime).toBe($2('#now').text())
38203804
}
38213805
})
38223806
}

test/e2e/app-dir/next-after-app-deploy/app/timestamp/key/[key]/page.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ export const revalidate = 3600 // arbitrarily long, just so that it doesn't happ
55
export const dynamicParams = true
66

77
export async function generateStaticParams() {
8-
return []
8+
return ['nodejs', 'edge'].flatMap((runtime) =>
9+
['dynamic-page', 'middleware', 'route', 'server-action'].map((page) => ({
10+
key: `/${runtime}/${page}`,
11+
}))
12+
)
913
}
1014

1115
export default async function Page({ params }) {

0 commit comments

Comments
 (0)