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
1498b366
Unverified
Commit
1498b366
authored
Aug 18, 2026
by
David Alexandru Ilie
Committed by
GitHub
Aug 18, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: show non-200 prerender statuses
parent
b18acf67
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
118 additions
and
2 deletions
+118
-2
index.ts
packages/next/src/build/index.ts
+11
-0
utils.ts
packages/next/src/build/utils.ts
+15
-2
index.ts
packages/next/src/export/index.ts
+3
-0
app-page.ts
packages/next/src/export/routes/app-page.ts
+3
-0
types.ts
packages/next/src/export/types.ts
+6
-0
build-output-tree-view.test.ts
...dir/build-output-tree-view/build-output-tree-view.test.ts
+28
-0
page.tsx
...e-view/fixtures/prerender-status/app/error-shell/page.tsx
+11
-0
page.tsx
...view/fixtures/prerender-status/app/healthy-shell/page.tsx
+23
-0
layout.tsx
...output-tree-view/fixtures/prerender-status/app/layout.tsx
+9
-0
not-found.tsx
...put-tree-view/fixtures/prerender-status/app/not-found.tsx
+3
-0
page.tsx
...d-output-tree-view/fixtures/prerender-status/app/page.tsx
+3
-0
next.config.js
...output-tree-view/fixtures/prerender-status/next.config.js
+3
-0
No files found.
packages/next/src/build/index.ts
View file @
1498b366
...
@@ -3460,6 +3460,7 @@ export default async function build(
...
@@ -3460,6 +3460,7 @@ export default async function build(
hasEmptyStaticShell
,
hasEmptyStaticShell
,
hasPostponed
,
hasPostponed
,
hasStaticRsc
,
hasStaticRsc
,
prerenderStatus
,
}
=
routeResult
??
{}
}
=
routeResult
??
{}
const
cacheControl
=
getCacheControl
(
const
cacheControl
=
getCacheControl
(
...
@@ -3482,6 +3483,11 @@ export default async function build(
...
@@ -3482,6 +3483,11 @@ export default async function build(
hasPostponed
,
hasPostponed
,
hasEmptyStaticShell
,
hasEmptyStaticShell
,
initialCacheControl
:
cacheControl
,
initialCacheControl
:
cacheControl
,
prerenderStatus
:
cacheControl
.
revalidate
!==
0
&&
route
.
pathname
!==
UNDERSCORE_NOT_FOUND_ROUTE
?
prerenderStatus
:
undefined
,
})
})
// update the page (eg /blog/[slug]) to also have the postpone metadata
// update the page (eg /blog/[slug]) to also have the postpone metadata
...
@@ -3748,6 +3754,11 @@ export default async function build(
...
@@ -3748,6 +3754,11 @@ export default async function build(
// if PPR is turned on and the route contains a dynamic segment,
// if PPR is turned on and the route contains a dynamic segment,
// we assume it'll be partially prerendered
// we assume it'll be partially prerendered
hasPostponed
:
isRoutePPREnabled
,
hasPostponed
:
isRoutePPREnabled
,
prerenderStatus
:
cacheControl
.
revalidate
!==
0
&&
route
.
pathname
!==
UNDERSCORE_NOT_FOUND_ROUTE
?
routeResult
?.
prerenderStatus
:
undefined
,
})
})
}
}
...
...
packages/next/src/build/utils.ts
View file @
1498b366
...
@@ -218,6 +218,8 @@ export interface PageInfo {
...
@@ -218,6 +218,8 @@ export interface PageInfo {
hasEmptyStaticShell
?:
boolean
hasEmptyStaticShell
?:
boolean
hasPostponed
?:
boolean
hasPostponed
?:
boolean
isDynamicAppRoute
?:
boolean
isDynamicAppRoute
?:
boolean
/** The HTTP status produced while prerendering this route. */
prerenderStatus
?:
number
}
}
export
type
PageInfos
=
Map
<
string
,
PageInfo
>
export
type
PageInfos
=
Map
<
string
,
PageInfo
>
...
@@ -264,6 +266,11 @@ function getTreeViewSymbol(
...
@@ -264,6 +266,11 @@ function getTreeViewSymbol(
return
'ƒ'
return
'ƒ'
}
}
function
getPrerenderStatusAnnotation
(
pageInfo
:
PageInfo
|
undefined
):
string
{
const
status
=
pageInfo
?.
prerenderStatus
return
status
!==
undefined
&&
status
!==
200
?
` [status:
${
status
}
]`
:
''
}
export
interface
RoutesUsingEdgeRuntime
{
export
interface
RoutesUsingEdgeRuntime
{
[
route
:
string
]:
0
[
route
:
string
]:
0
}
}
...
@@ -389,6 +396,9 @@ export async function printTreeView(
...
@@ -389,6 +396,9 @@ export async function printTreeView(
const
hasChildRoutes
=
Boolean
(
pageInfo
?.
ssgPageRoutes
?.
length
)
const
hasChildRoutes
=
Boolean
(
pageInfo
?.
ssgPageRoutes
?.
length
)
const
displayPath
=
getTreeViewDisplayPath
(
item
)
const
displayPath
=
getTreeViewDisplayPath
(
item
)
const
prerenderStatusAnnotation
=
hasChildRoutes
?
''
:
getPrerenderStatusAnnotation
(
pageInfo
)
if
(
hasGSPAndRevalidateZero
.
has
(
item
))
{
if
(
hasGSPAndRevalidateZero
.
has
(
item
))
{
usedSymbols
.
add
(
'ƒ'
)
usedSymbols
.
add
(
'ƒ'
)
...
@@ -414,7 +424,7 @@ export async function printTreeView(
...
@@ -414,7 +424,7 @@ export async function printTreeView(
}
}
messages
.
push
([
messages
.
push
([
`
${
border
}
${
hasChildRoutes
?
' '
:
symbol
}
${
displayPath
}${
`
${
border
}
${
hasChildRoutes
?
' '
:
symbol
}
${
displayPath
}${
prerenderStatusAnnotation
}${
totalDuration
>
MIN_DURATION
totalDuration
>
MIN_DURATION
?
` (
${
getPrettyDuration
(
totalDuration
)}
)`
?
` (
${
getPrettyDuration
(
totalDuration
)}
)`
:
''
:
''
...
@@ -481,12 +491,15 @@ export async function printTreeView(
...
@@ -481,12 +491,15 @@ export async function printTreeView(
const
routePageInfo
=
pageInfos
.
get
(
route
)
??
pageInfo
const
routePageInfo
=
pageInfos
.
get
(
route
)
??
pageInfo
const
routeSymbol
=
getTreeViewSymbol
(
route
,
routePageInfo
)
const
routeSymbol
=
getTreeViewSymbol
(
route
,
routePageInfo
)
usedSymbols
.
add
(
routeSymbol
)
usedSymbols
.
add
(
routeSymbol
)
const
childStatusAnnotation
=
getPrerenderStatusAnnotation
(
pageInfos
.
get
(
route
)
)
const
initialCacheControl
=
const
initialCacheControl
=
pageInfos
.
get
(
route
)?.
initialCacheControl
pageInfos
.
get
(
route
)?.
initialCacheControl
messages
.
push
([
messages
.
push
([
`
${
contSymbol
}
${
innerSymbol
}
${
routeSymbol
}
${
route
}${
`
${
contSymbol
}
${
innerSymbol
}
${
routeSymbol
}
${
route
}${
childStatusAnnotation
}${
duration
>
MIN_DURATION
duration
>
MIN_DURATION
?
` (
${
getPrettyDuration
(
duration
)}
)`
?
` (
${
getPrettyDuration
(
duration
)}
)`
:
''
:
''
...
...
packages/next/src/export/index.ts
View file @
1498b366
...
@@ -848,6 +848,9 @@ async function exportAppImpl(
...
@@ -848,6 +848,9 @@ async function exportAppImpl(
if
(
typeof
result
.
metadata
!==
'undefined'
)
{
if
(
typeof
result
.
metadata
!==
'undefined'
)
{
info
.
metadata
=
result
.
metadata
info
.
metadata
=
result
.
metadata
}
}
if
(
typeof
result
.
prerenderStatus
!==
'undefined'
)
{
info
.
prerenderStatus
=
result
.
prerenderStatus
}
if
(
typeof
result
.
hasEmptyStaticShell
!==
'undefined'
)
{
if
(
typeof
result
.
hasEmptyStaticShell
!==
'undefined'
)
{
info
.
hasEmptyStaticShell
=
result
.
hasEmptyStaticShell
info
.
hasEmptyStaticShell
=
result
.
hasEmptyStaticShell
...
...
packages/next/src/export/routes/app-page.ts
View file @
1498b366
...
@@ -252,6 +252,9 @@ export async function exportAppPage(
...
@@ -252,6 +252,9 @@ export async function exportAppPage(
segmentPaths
:
meta
.
segmentPaths
,
segmentPaths
:
meta
.
segmentPaths
,
prefetchHints
:
meta
.
prefetchHints
,
prefetchHints
:
meta
.
prefetchHints
,
},
},
// Keep the status available to build diagnostics even when deployment
// metadata is filtered in environments without Next.js support.
prerenderStatus
:
status
,
hasEmptyStaticShell
:
Boolean
(
postponed
)
&&
html
===
''
,
hasEmptyStaticShell
:
Boolean
(
postponed
)
&&
html
===
''
,
hasPostponed
:
Boolean
(
postponed
),
hasPostponed
:
Boolean
(
postponed
),
hasPendingUi
:
hasPendingUi
??
false
,
hasPendingUi
:
hasPendingUi
??
false
,
...
...
packages/next/src/export/types.ts
View file @
1498b366
...
@@ -69,6 +69,8 @@ export type ExportRouteResult =
...
@@ -69,6 +69,8 @@ export type ExportRouteResult =
|
{
|
{
cacheControl
:
CacheControl
cacheControl
:
CacheControl
metadata
?:
Partial
<
RouteMetadata
>
metadata
?:
Partial
<
RouteMetadata
>
/** The HTTP status produced while prerendering this route. */
prerenderStatus
?:
number
ssgNotFound
?:
boolean
ssgNotFound
?:
boolean
hasEmptyStaticShell
?:
boolean
hasEmptyStaticShell
?:
boolean
hasPostponed
?:
boolean
hasPostponed
?:
boolean
...
@@ -144,6 +146,10 @@ export type ExportAppResult = {
...
@@ -144,6 +146,10 @@ export type ExportAppResult = {
* The metadata for the page.
* The metadata for the page.
*/
*/
metadata
?:
Partial
<
RouteMetadata
>
metadata
?:
Partial
<
RouteMetadata
>
/**
* The HTTP status produced while prerendering the page.
*/
prerenderStatus
?:
number
/**
/**
* If the page has an empty static shell when using PPR.
* If the page has an empty static shell when using PPR.
*/
*/
...
...
test/production/app-dir/build-output-tree-view/build-output-tree-view.test.ts
View file @
1498b366
...
@@ -69,6 +69,34 @@ describe('build-output-tree-view', () => {
...
@@ -69,6 +69,34 @@ describe('build-output-tree-view', () => {
})
})
})
})
describe
(
'with a non-200 prerendered app route'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
path
.
join
(
__dirname
,
'fixtures/prerender-status'
),
skipStart
:
true
,
env
:
{
__NEXT_PRIVATE_DETERMINISTIC_BUILD_OUTPUT
:
'1'
,
},
})
beforeAll
(()
=>
next
.
build
())
it
(
'shows a known non-200 status on the user route only'
,
()
=>
{
const
treeView
=
getTreeView
(
next
.
cliOutput
)
expect
(
treeView
).
toContain
(
'◐ /error-shell [status: 404]'
)
expect
(
treeView
).
toContain
(
'◐ /healthy-shell'
)
expect
(
treeView
).
not
.
toContain
(
'/healthy-shell [status:'
)
expect
(
treeView
).
not
.
toContain
(
'/_not-found [status:'
)
})
it
(
'does not change the runtime response statuses'
,
async
()
=>
{
await
next
.
start
()
expect
((
await
next
.
fetch
(
'/error-shell'
)).
status
).
toBe
(
404
)
expect
((
await
next
.
fetch
(
'/healthy-shell'
)).
status
).
toBe
(
200
)
})
})
describe
(
'with generated app routes that mix static and partial outputs'
,
()
=>
{
describe
(
'with generated app routes that mix static and partial outputs'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
const
{
next
}
=
nextTestSetup
({
files
:
path
.
join
(
__dirname
,
'../../../e2e/app-dir/cache-components'
),
files
:
path
.
join
(
__dirname
,
'../../../e2e/app-dir/cache-components'
),
...
...
test/production/app-dir/build-output-tree-view/fixtures/prerender-status/app/error-shell/page.tsx
0 → 100644
View file @
1498b366
import
{
notFound
}
from
'next/navigation'
import
{
connection
}
from
'next/server'
export
async
function
generateMetadata
()
{
await
connection
()
return
{
title
:
'Runtime metadata'
}
}
export
default
function
ErrorShellPage
()
{
return
notFound
()
}
test/production/app-dir/build-output-tree-view/fixtures/prerender-status/app/healthy-shell/page.tsx
0 → 100644
View file @
1498b366
import
{
Suspense
}
from
'react'
import
{
connection
}
from
'next/server'
export
async
function
generateMetadata
()
{
await
connection
()
return
{
title
:
'Runtime metadata'
}
}
async
function
RuntimeMarker
()
{
await
connection
()
return
<
span
>
Runtime content
</
span
>
}
export
default
function
HealthyShellPage
()
{
return
(
<
p
>
Healthy shell
<
Suspense
fallback=
{
<
span
>
Loading runtime content
</
span
>
}
>
<
RuntimeMarker
/>
</
Suspense
>
</
p
>
)
}
test/production/app-dir/build-output-tree-view/fixtures/prerender-status/app/layout.tsx
0 → 100644
View file @
1498b366
export
default
function
RootLayout
({
children
,
}:
Readonly
<
{
children
:
React
.
ReactNode
}
>
)
{
return
(
<
html
lang=
"en"
>
<
body
>
{
children
}
</
body
>
</
html
>
)
}
test/production/app-dir/build-output-tree-view/fixtures/prerender-status/app/not-found.tsx
0 → 100644
View file @
1498b366
export
default
function
NotFound
()
{
return
<
p
>
Not found
</
p
>
}
test/production/app-dir/build-output-tree-view/fixtures/prerender-status/app/page.tsx
0 → 100644
View file @
1498b366
export
default
function
Home
()
{
return
<
p
>
Build-output status test
</
p
>
}
test/production/app-dir/build-output-tree-view/fixtures/prerender-status/next.config.js
0 → 100644
View file @
1498b366
module
.
exports
=
{
cacheComponents
:
true
,
}
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