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
e1f9057f
Unverified
Commit
e1f9057f
authored
Aug 27, 2026
by
David Alexandru Ilie
Committed by
GitHub
Aug 27, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make postponed resume mode explicit
parent
10b0db32
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
32 deletions
+52
-32
app-page-runtime.ts
packages/next/src/build/templates/app-page-runtime.ts
+18
-5
edge-ssr-app.ts
packages/next/src/build/templates/edge-ssr-app.ts
+1
-0
app-render.tsx
packages/next/src/server/app-render/app-render.tsx
+4
-20
types.ts
packages/next/src/server/app-render/types.ts
+8
-0
server-action-request-meta.ts
packages/next/src/server/lib/server-action-request-meta.ts
+3
-5
module.ts
packages/next/src/server/route-modules/app-page/module.ts
+2
-2
cache-components.server-action.test.ts
...r/cache-components/cache-components.server-action.test.ts
+16
-0
No files found.
packages/next/src/build/templates/app-page-runtime.ts
View file @
e1f9057f
import
type
{
LoaderTree
}
from
'../../server/lib/app-dir-module'
import
type
{
LoaderTree
}
from
'../../server/lib/app-dir-module'
import
type
{
IncomingMessage
,
ServerResponse
}
from
'node:http'
import
type
{
IncomingMessage
,
ServerResponse
}
from
'node:http'
import
type
{
FallbackRouteParam
}
from
'../static-paths/types'
import
type
{
FallbackRouteParam
}
from
'../static-paths/types'
import
type
{
AppPageRenderOperation
}
from
'../../server/app-render/types'
import
{
import
{
AppPageRouteModule
,
AppPageRouteModule
,
...
@@ -90,8 +91,6 @@ import { InvariantError } from '../../shared/lib/invariant-error' with { 'turbop
...
@@ -90,8 +91,6 @@ import { InvariantError } from '../../shared/lib/invariant-error' with { 'turbop
import
{
scheduleOnNextTick
}
from
'../../lib/scheduler'
with
{
'turbopack-transition'
:
'next-server-utility'
}
import
{
scheduleOnNextTick
}
from
'../../lib/scheduler'
with
{
'turbopack-transition'
:
'next-server-utility'
}
import
{
getSegmentParam
}
from
'../../shared/lib/router/utils/get-segment-param'
with
{
'turbopack-transition'
:
'next-server-utility'
}
import
{
getSegmentParam
}
from
'../../shared/lib/router/utils/get-segment-param'
with
{
'turbopack-transition'
:
'next-server-utility'
}
type
AppPageRenderOperation
=
'render'
|
'prerender'
/**
/**
* Builds the cache key for the most complete prerenderable shell we can derive
* Builds the cache key for the most complete prerenderable shell we can derive
* from the shell that matched this request. Only params that can still be
* from the shell that matched this request. Only params that can still be
...
@@ -861,10 +860,11 @@ export function createAppPageEntrypoint({
...
@@ -861,10 +860,11 @@ export function createAppPageEntrypoint({
routeModule
,
routeModule
,
page
:
srcPage
,
page
:
srcPage
,
postponed
,
postponed
,
renderOperation
,
allowEmptyStaticShell
,
allowEmptyStaticShell
,
serveStreamingMetadata
,
serveStreamingMetadata
,
supportsDynamicResponse
:
supportsDynamicResponse
:
renderOperation
===
'
render'
&&
renderOperation
!==
'pre
render'
&&
(
typeof
postponed
===
'string'
||
supportsDynamicResponse
),
(
typeof
postponed
===
'string'
||
supportsDynamicResponse
),
buildManifest
,
buildManifest
,
nextFontManifest
,
nextFontManifest
,
...
@@ -1567,12 +1567,25 @@ export function createAppPageEntrypoint({
...
@@ -1567,12 +1567,25 @@ export function createAppPageEntrypoint({
!
isDebugPrerender
&&
!
isDebugPrerender
&&
(
supportsDynamicResponse
||
isPossibleServerAction
)
(
supportsDynamicResponse
||
isPossibleServerAction
)
const
isResumeRender
=
!
forceStaticRender
&&
!
isDebugPrerender
&&
typeof
postponed
===
'string'
&&
hasPostponedState
&&
!
isPossibleServerAction
const
renderOperation
:
AppPageRenderOperation
=
isResumeRender
?
'resume'
:
isRequestSpecificRender
?
'render'
:
'prerender'
// Perform the render.
// Perform the render.
return
doRender
({
return
doRender
({
span
,
span
,
postponed
,
postponed
,
fallbackRouteParams
,
fallbackRouteParams
,
renderOperation
:
isRequestSpecificRender
?
'render'
:
'prerender'
,
renderOperation
,
allowEmptyStaticShell
:
isInstantNavigationTest
||
undefined
,
allowEmptyStaticShell
:
isInstantNavigationTest
||
undefined
,
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
...
@@ -2109,7 +2122,7 @@ export function createAppPageEntrypoint({
...
@@ -2109,7 +2122,7 @@ export function createAppPageEntrypoint({
// This is a resume render, not a fallback render. Fallback params
// This is a resume render, not a fallback render. Fallback params
// (for cacheComponents routes) are plumbed via request meta above.
// (for cacheComponents routes) are plumbed via request meta above.
fallbackRouteParams
:
null
,
fallbackRouteParams
:
null
,
renderOperation
:
're
nder
'
,
renderOperation
:
're
sume
'
,
})
})
.
then
(
async
(
result
)
=>
{
.
then
(
async
(
result
)
=>
{
if
(
!
result
)
{
if
(
!
result
)
{
...
...
packages/next/src/build/templates/edge-ssr-app.ts
View file @
e1f9057f
...
@@ -131,6 +131,7 @@ async function requestHandler(
...
@@ -131,6 +131,7 @@ async function requestHandler(
params
,
params
,
page
:
srcPage
,
page
:
srcPage
,
postponed
:
undefined
,
postponed
:
undefined
,
renderOperation
:
'render'
,
serveStreamingMetadata
:
true
,
serveStreamingMetadata
:
true
,
supportsDynamicResponse
:
true
,
supportsDynamicResponse
:
true
,
buildManifest
,
buildManifest
,
...
...
packages/next/src/server/app-render/app-render.tsx
View file @
e1f9057f
...
@@ -3324,11 +3324,10 @@ function prepareAppPage(
...
@@ -3324,11 +3324,10 @@ function prepareAppPage(
)
)
// If provided, parse the postponed state so its RDC is available to the
// If provided, parse the postponed state so its RDC is available to the
// render.
Keep the React state only for requests that can resume it.
// render.
let
postponedState
:
PostponedState
|
null
=
null
let
postponedState
:
PostponedState
|
null
=
null
if
(
typeof
renderOpts
.
postponed
===
'string'
)
{
if
(
typeof
renderOpts
.
postponed
===
'string'
)
{
const
{
isFetchAction
,
isPossibleMPAAction
}
=
const
{
isFetchAction
}
=
getServerActionRequestMetadata
(
req
)
getServerActionRequestMetadata
(
req
)
if
(
fallbackRouteParams
)
{
if
(
fallbackRouteParams
)
{
if
(
!
isFetchAction
)
{
if
(
!
isFetchAction
)
{
...
@@ -3348,18 +3347,6 @@ function prepareAppPage(
...
@@ -3348,18 +3347,6 @@ function prepareAppPage(
renderOpts
.
experimental
.
disableResumeDataCacheCompression
renderOpts
.
experimental
.
disableResumeDataCacheCompression
),
),
}
}
}
else
if
(
isPossibleMPAAction
)
{
// An MPA action needs a complete HTML document, so it cannot resume the
// React render. Its RDC is still needed to keep cached values consistent
// with the static shell when the action did not invalidate them.
postponedState
=
{
type
:
DynamicState
.
DATA
,
renderResumeDataCache
:
parseResumeDataCacheFromPostponedState
(
renderOpts
.
postponed
,
renderOpts
.
experimental
.
maxPostponedStateSizeBytes
,
renderOpts
.
experimental
.
disableResumeDataCacheCompression
),
}
}
else
{
}
else
{
postponedState
=
parsePostponedState
(
postponedState
=
parsePostponedState
(
renderOpts
.
postponed
,
renderOpts
.
postponed
,
...
@@ -3548,8 +3535,6 @@ async function renderToStream(
...
@@ -3548,8 +3535,6 @@ async function renderToStream(
):
Promise
<
AnyStream
>
{
):
Promise
<
AnyStream
>
{
/* eslint-disable @next/internal/no-ambiguous-jsx -- React Client */
/* eslint-disable @next/internal/no-ambiguous-jsx -- React Client */
// MARK: renderToStream setup
// MARK: renderToStream setup
const
{
isPossibleMPAAction
}
=
getServerActionRequestMetadata
(
req
)
const
{
const
{
assetPrefix
,
assetPrefix
,
htmlRequestId
,
htmlRequestId
,
...
@@ -3559,10 +3544,9 @@ async function renderToStream(
...
@@ -3559,10 +3544,9 @@ async function renderToStream(
requestId
,
requestId
,
workStore
,
workStore
,
}
=
ctx
}
=
ctx
// MPA actions reuse the RDC from the postponed state, but their response
// must come from a complete server render rather than a postponed response.
const
shouldUsePostponedResponse
=
const
shouldUsePostponedResponse
=
typeof
renderOpts
.
postponed
===
'string'
&&
!
isPossibleMPAAction
typeof
renderOpts
.
postponed
===
'string'
&&
renderOpts
.
renderOperation
===
'resume'
const
{
const
{
basePath
,
basePath
,
...
...
packages/next/src/server/app-render/types.ts
View file @
e1f9057f
...
@@ -91,6 +91,8 @@ export type ServerOnInstrumentationRequestError = (
...
@@ -91,6 +91,8 @@ export type ServerOnInstrumentationRequestError = (
silenceLog
:
boolean
silenceLog
:
boolean
)
=>
void
|
Promise
<
void
>
)
=>
void
|
Promise
<
void
>
export
type
AppPageRenderOperation
=
'render'
|
'prerender'
|
'resume'
export
interface
RenderOptsPartial
{
export
interface
RenderOptsPartial
{
dir
?:
string
dir
?:
string
previewProps
:
__ApiPreviewProps
|
undefined
previewProps
:
__ApiPreviewProps
|
undefined
...
@@ -102,6 +104,12 @@ export interface RenderOptsPartial {
...
@@ -102,6 +104,12 @@ export interface RenderOptsPartial {
trailingSlash
:
boolean
trailingSlash
:
boolean
images
:
ImageConfigComplete
images
:
ImageConfigComplete
supportsDynamicResponse
:
boolean
supportsDynamicResponse
:
boolean
/**
* Describes how the outer runtime will compose this render's HTML. A resume
* render is appended to an existing shell; render and prerender operations
* must produce standalone output.
*/
renderOperation
?:
AppPageRenderOperation
runtime
?:
ServerRuntime
runtime
?:
ServerRuntime
serverComponents
?:
boolean
serverComponents
?:
boolean
enableTainting
?:
boolean
enableTainting
?:
boolean
...
...
packages/next/src/server/lib/server-action-request-meta.ts
View file @
e1f9057f
...
@@ -10,7 +10,6 @@ export function getServerActionRequestMetadata(
...
@@ -10,7 +10,6 @@ export function getServerActionRequestMetadata(
isURLEncodedAction
:
boolean
isURLEncodedAction
:
boolean
isMultipartAction
:
boolean
isMultipartAction
:
boolean
isFetchAction
:
boolean
isFetchAction
:
boolean
isPossibleMPAAction
:
boolean
isPossibleServerAction
:
boolean
isPossibleServerAction
:
boolean
}
{
}
{
let
actionId
:
string
|
null
let
actionId
:
string
|
null
...
@@ -38,17 +37,16 @@ export function getServerActionRequestMetadata(
...
@@ -38,17 +37,16 @@ export function getServerActionRequestMetadata(
typeof
actionId
===
'string'
&&
typeof
actionId
===
'string'
&&
req
.
method
===
'POST'
req
.
method
===
'POST'
)
)
const
isPossibleMPAAction
=
!
isFetchAction
&&
(
isURLEncodedAction
||
isMultipartAction
)
const
isPossibleServerAction
=
Boolean
(
isFetchAction
||
isPossibleMPAAction
)
const
isPossibleServerAction
=
Boolean
(
isFetchAction
||
isURLEncodedAction
||
isMultipartAction
)
return
{
return
{
actionId
,
actionId
,
isURLEncodedAction
,
isURLEncodedAction
,
isMultipartAction
,
isMultipartAction
,
isFetchAction
,
isFetchAction
,
isPossibleMPAAction
,
isPossibleServerAction
,
isPossibleServerAction
,
}
}
}
}
...
...
packages/next/src/server/route-modules/app-page/module.ts
View file @
e1f9057f
import
type
{
AppPageRouteDefinition
}
from
'../../route-definitions/app-page-route-definition'
import
type
{
AppPageRouteDefinition
}
from
'../../route-definitions/app-page-route-definition'
import
type
RenderResult
from
'../../render-result'
import
type
RenderResult
from
'../../render-result'
import
type
{
RenderOpts
}
from
'../../app-render/types'
import
type
{
AppPageRenderOperation
,
RenderOpts
}
from
'../../app-render/types'
import
{
addRequestMeta
,
type
NextParsedUrlQuery
}
from
'../../request-meta'
import
{
addRequestMeta
,
type
NextParsedUrlQuery
}
from
'../../request-meta'
import
type
{
LoaderTree
}
from
'../../lib/app-dir-module'
import
type
{
LoaderTree
}
from
'../../lib/app-dir-module'
import
type
{
PrerenderManifest
}
from
'../../../build'
import
type
{
PrerenderManifest
}
from
'../../../build'
...
@@ -75,7 +75,7 @@ export interface AppPageRouteHandlerContext extends RouteModuleHandleContext {
...
@@ -75,7 +75,7 @@ export interface AppPageRouteHandlerContext extends RouteModuleHandleContext {
page
:
string
page
:
string
query
:
NextParsedUrlQuery
query
:
NextParsedUrlQuery
fallbackRouteParams
:
OpaqueFallbackRouteParams
|
null
fallbackRouteParams
:
OpaqueFallbackRouteParams
|
null
renderOpts
:
RenderOpts
renderOpts
:
RenderOpts
&
{
renderOperation
:
AppPageRenderOperation
}
serverComponentsHmrCache
?:
ServerComponentsHmrCache
serverComponentsHmrCache
?:
ServerComponentsHmrCache
sharedContext
:
AppSharedContext
sharedContext
:
AppSharedContext
}
}
...
...
test/e2e/app-dir/cache-components/cache-components.server-action.test.ts
View file @
e1f9057f
...
@@ -55,6 +55,22 @@ describe('cache-components', () => {
...
@@ -55,6 +55,22 @@ describe('cache-components', () => {
})
})
})
})
it
(
'should return complete HTML for an unrelated urlencoded POST'
,
async
()
=>
{
const
response
=
await
next
.
fetch
(
'/server-action-mpa-partial'
,
{
method
:
'POST'
,
headers
:
{
'content-type'
:
'application/x-www-form-urlencoded'
,
},
body
:
'foo=bar'
,
})
const
html
=
await
response
.
text
()
expect
(
response
.
status
).
toBe
(
200
)
expect
(
html
).
toStartWith
(
'<!DOCTYPE html>'
)
expect
(
html
).
toContain
(
'id="cached-timestamp"'
)
expect
(
html
).
toEndWith
(
'</body></html>'
)
})
it
(
'should not have cache components errors when encoding bound args for inline server actions'
,
async
()
=>
{
it
(
'should not have cache components errors when encoding bound args for inline server actions'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/server-action-inline'
)
const
browser
=
await
next
.
browser
(
'/server-action-inline'
)
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toBe
(
'initial'
)
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toBe
(
'initial'
)
...
...
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