Skip to content

Commit 9aefe52

Browse files
authored
fix PPR build output logs (vercel#58149)
Fixes two build output logs: - A page that uses `generateStaticParams` & postpones should be marked as partially prerendered - Assume pages that contain dynamic segments will postpone when PPR is enabled even though it won't be determined until request time
1 parent d3756fa commit 9aefe52

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

packages/next/src/build/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,6 +2301,13 @@ export default async function build(
23012301
hasEmptyPrelude,
23022302
})
23032303

2304+
// update the page (eg /blog/[slug]) to also have the postpone metadata
2305+
pageInfos.set(page, {
2306+
...(pageInfos.get(page) as PageInfo),
2307+
hasPostponed,
2308+
hasEmptyPrelude,
2309+
})
2310+
23042311
if (revalidate !== 0) {
23052312
const normalizedRoute = normalizePagePath(route)
23062313

@@ -2386,6 +2393,9 @@ export default async function build(
23862393
pageInfos.set(page, {
23872394
...(pageInfos.get(page) as PageInfo),
23882395
isDynamicAppRoute: true,
2396+
// if PPR is turned on and the route contains a dynamic segment,
2397+
// we assume it'll be partially prerendered
2398+
hasPostponed: experimentalPPR,
23892399
})
23902400

23912401
// TODO: create a separate manifest to allow enforcing

packages/next/src/build/utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,13 @@ export async function printTreeView(
459459
} else if (isEdgeRuntime(pageInfo?.runtime)) {
460460
symbol = 'ℇ'
461461
} else if (pageInfo?.isPPR) {
462-
// If the page has an empty prelude, then it's equivalent to a static page.
463-
if (pageInfo?.hasEmptyPrelude || pageInfo.isDynamicAppRoute) {
462+
if (
463+
// If the page has an empty prelude, then it's equivalent to a dynamic page
464+
pageInfo?.hasEmptyPrelude ||
465+
// ensure we don't mark dynamic paths that postponed as being dynamic
466+
// since in this case we're able to partially prerender it
467+
(pageInfo.isDynamicAppRoute && !pageInfo.hasPostponed)
468+
) {
464469
symbol = 'λ'
465470
} else if (!pageInfo?.hasPostponed) {
466471
symbol = '○'

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ createNextDescribe(
66
files: __dirname,
77
skipDeployment: true,
88
},
9-
({ next, isNextDev }) => {
9+
({ next, isNextDev, isNextStart }) => {
10+
if (isNextStart) {
11+
describe('build output', () => {
12+
it('correctly marks pages as being partially prerendered in the build output', () => {
13+
expect(next.cliOutput).toContain('◐ /loading/nested/[slug]')
14+
expect(next.cliOutput).toContain('◐ /suspense/node')
15+
expect(next.cliOutput).toContain('◐ /suspense/node/gsp/[slug]')
16+
expect(next.cliOutput).toContain('◐ /suspense/node/nested/[slug]')
17+
})
18+
})
19+
}
1020
describe.each([
1121
{ pathname: '/suspense/node' },
1222
{ pathname: '/suspense/node/nested/1' },

0 commit comments

Comments
 (0)