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
{
IncomingMessage
,
ServerResponse
}
from
'node:http'
import
type
{
FallbackRouteParam
}
from
'../static-paths/types'
import
type
{
AppPageRenderOperation
}
from
'../../server/app-render/types'
import
{
AppPageRouteModule
,
...
...
@@ -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
{
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
* from the shell that matched this request. Only params that can still be
...
...
@@ -861,10 +860,11 @@ export function createAppPageEntrypoint({
routeModule
,
page
:
srcPage
,
postponed
,
renderOperation
,
allowEmptyStaticShell
,
serveStreamingMetadata
,
supportsDynamicResponse
:
renderOperation
===
'
render'
&&
renderOperation
!==
'pre
render'
&&
(
typeof
postponed
===
'string'
||
supportsDynamicResponse
),
buildManifest
,
nextFontManifest
,
...
...
@@ -1567,12 +1567,25 @@ export function createAppPageEntrypoint({
!
isDebugPrerender
&&
(
supportsDynamicResponse
||
isPossibleServerAction
)
const
isResumeRender
=
!
forceStaticRender
&&
!
isDebugPrerender
&&
typeof
postponed
===
'string'
&&
hasPostponedState
&&
!
isPossibleServerAction
const
renderOperation
:
AppPageRenderOperation
=
isResumeRender
?
'resume'
:
isRequestSpecificRender
?
'render'
:
'prerender'
// Perform the render.
return
doRender
({
span
,
postponed
,
fallbackRouteParams
,
renderOperation
:
isRequestSpecificRender
?
'render'
:
'prerender'
,
renderOperation
,
allowEmptyStaticShell
:
isInstantNavigationTest
||
undefined
,
})
}
catch
(
err
)
{
...
...
@@ -2109,7 +2122,7 @@ export function createAppPageEntrypoint({
// This is a resume render, not a fallback render. Fallback params
// (for cacheComponents routes) are plumbed via request meta above.
fallbackRouteParams
:
null
,
renderOperation
:
're
nder
'
,
renderOperation
:
're
sume
'
,
})
.
then
(
async
(
result
)
=>
{
if
(
!
result
)
{
...
...
packages/next/src/build/templates/edge-ssr-app.ts
View file @
e1f9057f
...
...
@@ -131,6 +131,7 @@ async function requestHandler(
params
,
page
:
srcPage
,
postponed
:
undefined
,
renderOperation
:
'render'
,
serveStreamingMetadata
:
true
,
supportsDynamicResponse
:
true
,
buildManifest
,
...
...
packages/next/src/server/app-render/app-render.tsx
View file @
e1f9057f
...
...
@@ -3324,11 +3324,10 @@ function prepareAppPage(
)
// 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
if
(
typeof
renderOpts
.
postponed
===
'string'
)
{
const
{
isFetchAction
,
isPossibleMPAAction
}
=
getServerActionRequestMetadata
(
req
)
const
{
isFetchAction
}
=
getServerActionRequestMetadata
(
req
)
if
(
fallbackRouteParams
)
{
if
(
!
isFetchAction
)
{
...
...
@@ -3348,18 +3347,6 @@ function prepareAppPage(
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
{
postponedState
=
parsePostponedState
(
renderOpts
.
postponed
,
...
...
@@ -3548,8 +3535,6 @@ async function renderToStream(
):
Promise
<
AnyStream
>
{
/* eslint-disable @next/internal/no-ambiguous-jsx -- React Client */
// MARK: renderToStream setup
const
{
isPossibleMPAAction
}
=
getServerActionRequestMetadata
(
req
)
const
{
assetPrefix
,
htmlRequestId
,
...
...
@@ -3559,10 +3544,9 @@ async function renderToStream(
requestId
,
workStore
,
}
=
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
=
typeof
renderOpts
.
postponed
===
'string'
&&
!
isPossibleMPAAction
typeof
renderOpts
.
postponed
===
'string'
&&
renderOpts
.
renderOperation
===
'resume'
const
{
basePath
,
...
...
packages/next/src/server/app-render/types.ts
View file @
e1f9057f
...
...
@@ -91,6 +91,8 @@ export type ServerOnInstrumentationRequestError = (
silenceLog
:
boolean
)
=>
void
|
Promise
<
void
>
export
type
AppPageRenderOperation
=
'render'
|
'prerender'
|
'resume'
export
interface
RenderOptsPartial
{
dir
?:
string
previewProps
:
__ApiPreviewProps
|
undefined
...
...
@@ -102,6 +104,12 @@ export interface RenderOptsPartial {
trailingSlash
:
boolean
images
:
ImageConfigComplete
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
serverComponents
?:
boolean
enableTainting
?:
boolean
...
...
packages/next/src/server/lib/server-action-request-meta.ts
View file @
e1f9057f
...
...
@@ -10,7 +10,6 @@ export function getServerActionRequestMetadata(
isURLEncodedAction
:
boolean
isMultipartAction
:
boolean
isFetchAction
:
boolean
isPossibleMPAAction
:
boolean
isPossibleServerAction
:
boolean
}
{
let
actionId
:
string
|
null
...
...
@@ -38,17 +37,16 @@ export function getServerActionRequestMetadata(
typeof
actionId
===
'string'
&&
req
.
method
===
'POST'
)
const
isPossibleMPAAction
=
!
isFetchAction
&&
(
isURLEncodedAction
||
isMultipartAction
)
const
isPossibleServerAction
=
Boolean
(
isFetchAction
||
isPossibleMPAAction
)
const
isPossibleServerAction
=
Boolean
(
isFetchAction
||
isURLEncodedAction
||
isMultipartAction
)
return
{
actionId
,
isURLEncodedAction
,
isMultipartAction
,
isFetchAction
,
isPossibleMPAAction
,
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
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
type
{
LoaderTree
}
from
'../../lib/app-dir-module'
import
type
{
PrerenderManifest
}
from
'../../../build'
...
...
@@ -75,7 +75,7 @@ export interface AppPageRouteHandlerContext extends RouteModuleHandleContext {
page
:
string
query
:
NextParsedUrlQuery
fallbackRouteParams
:
OpaqueFallbackRouteParams
|
null
renderOpts
:
RenderOpts
renderOpts
:
RenderOpts
&
{
renderOperation
:
AppPageRenderOperation
}
serverComponentsHmrCache
?:
ServerComponentsHmrCache
sharedContext
:
AppSharedContext
}
...
...
test/e2e/app-dir/cache-components/cache-components.server-action.test.ts
View file @
e1f9057f
...
...
@@ -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
()
=>
{
const
browser
=
await
next
.
browser
(
'/server-action-inline'
)
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