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
ffeaa8f3
Unverified
Commit
ffeaa8f3
authored
Nov 06, 2023
by
Wyatt Johnson
Committed by
GitHub
Nov 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: normalization and invariant fixes for ppr (#58105)
parent
03002123
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
19 deletions
+9
-19
base-server.ts
packages/next/src/server/base-server.ts
+9
-19
No files found.
packages/next/src/server/base-server.ts
View file @
ffeaa8f3
...
@@ -958,12 +958,14 @@ export default abstract class Server<ServerOptions extends Options = Options> {
...
@@ -958,12 +958,14 @@ export default abstract class Server<ServerOptions extends Options = Options> {
'http://localhost'
'http://localhost'
)
)
const
{
pathname
:
urlPathname
}
=
new
URL
(
req
.
url
,
'http://localhost'
)
// For ISR the URL is normalized to the prerenderPath so if
// For ISR the URL is normalized to the prerenderPath so if
// it's a data request the URL path will be the data URL,
// it's a data request the URL path will be the data URL,
// basePath is already stripped by this point
// basePath is already stripped by this point
if
(
if
(
this
.
enabledDirectories
.
pages
&&
this
.
enabledDirectories
.
pages
&&
this
.
normalizers
.
data
.
match
(
parsedUrl
.
p
athname
)
this
.
normalizers
.
data
.
match
(
urlP
athname
)
)
{
)
{
parsedUrl
.
query
.
__nextDataReq
=
'1'
parsedUrl
.
query
.
__nextDataReq
=
'1'
}
}
...
@@ -1888,7 +1890,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
...
@@ -1888,7 +1890,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
// we can use this fact to only generate the flight data for the request
// we can use this fact to only generate the flight data for the request
// because we can't cache the HTML (as it's also dynamic).
// because we can't cache the HTML (as it's also dynamic).
const
isDynamicRSCRequest
=
const
isDynamicRSCRequest
=
this
.
renderO
pts
.
experimental
.
ppr
&&
isRSCRequest
&&
!
isPrefetchRSCRequest
o
pts
.
experimental
.
ppr
&&
isRSCRequest
&&
!
isPrefetchRSCRequest
// For pages we need to ensure the correct Vary header is set too, to avoid
// For pages we need to ensure the correct Vary header is set too, to avoid
// caching issues when navigating between pages and app
// caching issues when navigating between pages and app
...
@@ -2138,13 +2140,13 @@ export default abstract class Server<ServerOptions extends Options = Options> {
...
@@ -2138,13 +2140,13 @@ export default abstract class Server<ServerOptions extends Options = Options> {
const
doRender
:
Renderer
=
async
(
postponed
)
=>
{
const
doRender
:
Renderer
=
async
(
postponed
)
=>
{
// In development, we always want to generate dynamic HTML.
// In development, we always want to generate dynamic HTML.
const
supportsDynamicHTML
=
const
supportsDynamicHTML
:
boolean
=
// If this isn't a data request and we're not in development, then we
// If this isn't a data request and we're not in development, then we
// support dynamic HTML.
// support dynamic HTML.
(
!
isDataReq
&&
opts
.
dev
)
||
(
!
isDataReq
&&
opts
.
dev
===
true
)
||
// If this is not SSG or does not have static paths, then it supports
// If this is not SSG or does not have static paths, then it supports
// dynamic HTML.
// dynamic HTML.
!
(
isSSG
||
hasStaticPaths
)
||
(
!
isSSG
&&
!
hasStaticPaths
)
||
// If this request has provided postponed data, it supports dynamic
// If this request has provided postponed data, it supports dynamic
// HTML.
// HTML.
!!
postponed
||
!!
postponed
||
...
@@ -2152,18 +2154,6 @@ export default abstract class Server<ServerOptions extends Options = Options> {
...
@@ -2152,18 +2154,6 @@ export default abstract class Server<ServerOptions extends Options = Options> {
// HTML (it's dynamic).
// HTML (it's dynamic).
isDynamicRSCRequest
isDynamicRSCRequest
// Ensure we bail if a prefetch RSC request is made while PPR is
// enabled that has dynamic HTML enabled.
if
(
this
.
renderOpts
.
experimental
.
ppr
&&
isPrefetchRSCRequest
&&
supportsDynamicHTML
)
{
throw
new
Error
(
"Invariant: prefetch RSC requests can't support dynamic HTML"
)
}
let
headers
:
OutgoingHttpHeaders
|
undefined
let
headers
:
OutgoingHttpHeaders
|
undefined
const
origQuery
=
parseUrl
(
req
.
url
||
''
,
true
).
query
const
origQuery
=
parseUrl
(
req
.
url
||
''
,
true
).
query
...
@@ -2317,7 +2307,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
...
@@ -2317,7 +2307,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
)
)
}
else
if
(
isAppPageRouteModule
(
routeModule
))
{
}
else
if
(
isAppPageRouteModule
(
routeModule
))
{
if
(
if
(
!
this
.
renderO
pts
.
experimental
.
ppr
&&
!
o
pts
.
experimental
.
ppr
&&
isPrefetchRSCRequest
&&
isPrefetchRSCRequest
&&
process
.
env
.
NODE_ENV
===
'production'
&&
process
.
env
.
NODE_ENV
===
'production'
&&
!
this
.
minimalMode
!
this
.
minimalMode
...
@@ -2655,7 +2645,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
...
@@ -2655,7 +2645,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
this
.
minimalMode
&&
this
.
minimalMode
&&
isRSCRequest
&&
isRSCRequest
&&
!
isPrefetchRSCRequest
&&
!
isPrefetchRSCRequest
&&
this
.
renderO
pts
.
experimental
.
ppr
o
pts
.
experimental
.
ppr
)
{
)
{
revalidate
=
0
revalidate
=
0
}
else
if
(
}
else
if
(
...
...
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