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
23252b94
Unverified
Commit
23252b94
authored
Dec 06, 2023
by
Wyatt Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: when ppr is enabled, generate prefetch during static generation
parent
1f6defd4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
app-render.tsx
packages/next/src/server/app-render/app-render.tsx
+21
-4
No files found.
packages/next/src/server/app-render/app-render.tsx
View file @
23252b94
...
...
@@ -237,7 +237,11 @@ function makeGetDynamicParamFromSegment(
}
}
// Handle Flight render request. This is only used when client-side navigating. E.g. when you `router.push('/dashboard')` or `router.reload()`.
/**
* Handles rendering the RSC payload for a request. This is only used when
* client-side navigating. Like when you `router.push('/dashboard')` or
* `router.reload()`.
*/
async
function
generateFlight
(
ctx
:
AppRenderContext
,
options
?:
{
...
...
@@ -583,10 +587,15 @@ async function renderToHTMLOrFlightImpl(
req
.
headers
[
NEXT_ROUTER_PREFETCH_HEADER
.
toLowerCase
()]
!==
undefined
/**
* Router state provided from the client-side router. Used to handle rendering from the common layout down.
* Router state provided from the client-side router. Used to handle rendering
* from the common layout down.
*/
let
providedFlightRouterState
=
isRSCRequest
&&
(
!
isPrefetchRSCRequest
||
!
renderOpts
.
experimental
.
ppr
)
// We'll only have a flight router state if this is a flight request.
isRSCRequest
&&
// When PPR is enabled, we won't have the flight router state during a
// prefetch request.
(
!
isPrefetchRSCRequest
||
!
renderOpts
.
experimental
.
ppr
)
?
parseAndValidateFlightRouterState
(
req
.
headers
[
NEXT_ROUTER_STATE_TREE
.
toLowerCase
()]
)
...
...
@@ -625,7 +634,12 @@ async function renderToHTMLOrFlightImpl(
...
baseCtx
,
getDynamicParamFromSegment
,
query
,
isPrefetch
:
isPrefetchRSCRequest
,
// We should treat this as a prefetch request if the prefetch header is
// present (meaning this is a prefetch request) or we're generating static
// HTML (meaning this is a revalidation request) while PPR is enabled.
isPrefetch
:
isPrefetchRSCRequest
||
(
renderOpts
.
experimental
.
ppr
&&
isStaticGeneration
),
providedSearchParams
,
requestTimestamp
,
searchParamsProps
,
...
...
@@ -642,6 +656,9 @@ async function renderToHTMLOrFlightImpl(
res
,
}
// If this is an RSC request, and this isn't during static generation, then
// we don't need to render the HTML, we just need to generate the flight
// payload.
if
(
isRSCRequest
&&
!
isStaticGeneration
)
{
return
generateFlight
(
ctx
)
}
...
...
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