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
44b1e3a7
Commit
44b1e3a7
authored
Mar 05, 2025
by
Janka Uryga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inline returns into branches
parent
43a4869f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
23 deletions
+36
-23
action-handler.ts
packages/next/src/server/app-render/action-handler.ts
+36
-23
No files found.
packages/next/src/server/app-render/action-handler.ts
View file @
44b1e3a7
...
...
@@ -612,13 +612,8 @@ export async function handleAction({
'no-cache, no-store, max-age=0, must-revalidate'
)
let
boundActionArguments
:
unknown
[]
=
[]
const
{
actionAsyncStorage
}
=
ComponentMod
let
actionResult
:
RenderResult
|
undefined
let
formState
:
any
|
undefined
let
actionModId
:
string
|
undefined
const
actionWasForwarded
=
Boolean
(
req
.
headers
[
'x-action-forwarded'
])
if
(
actionId
)
{
...
...
@@ -646,9 +641,13 @@ export async function handleAction({
}
try
{
await
actionAsyncStorage
.
run
(
return
await
actionAsyncStorage
.
run
(
{
isAction
:
true
},
async
():
Promise
<
void
>
=>
{
async
():
Promise
<
HandleActionResult
>
=>
{
// We only use these two for fetch actions -- no-js actions handle all of this via `decodeAction`.
let
actionModId
:
string
let
boundActionArguments
:
unknown
[]
if
(
// The type check here ensures that `req` is correctly typed, and the
// environment variable check provides dead code elimination.
...
...
@@ -697,15 +696,20 @@ export async function handleAction({
action
)
formState
=
await
decodeFormState
(
const
formState
=
await
decodeFormState
(
actionReturnedState
,
formData
,
serverModuleMap
)
requestStore
.
phase
=
'render'
// Skip the fetch path
return
return
{
type
:
'done'
,
result
:
undefined
,
formState
,
}
}
else
{
// We couldn't decode an action, so this is a non-action POST request.
throw
new
NotAServerActionError
()
...
...
@@ -862,7 +866,7 @@ export async function handleAction({
action
)
formState
=
await
decodeFormState
(
const
formState
=
await
decodeFormState
(
actionReturnedState
,
formData
,
serverModuleMap
...
...
@@ -871,7 +875,11 @@ export async function handleAction({
requestStore
.
phase
=
'render'
// Skip the fetch path
return
return
{
type
:
'done'
,
result
:
undefined
,
formState
,
}
}
else
{
// We couldn't decode an action, so this is a non-action POST request.
throw
new
NotAServerActionError
()
...
...
@@ -953,20 +961,25 @@ export async function handleAction({
requestStore
,
})
actionResult
=
await
finalizeAndGenerateFlight
(
req
,
ctx
,
requestStore
,
{
actionResult
:
Promise
.
resolve
(
returnVal
),
// if the page was not revalidated, or if the action was forwarded from another worker, we can skip the rendering the flight tree
skipFlight
:
!
workStore
.
pathWasRevalidated
||
actionWasForwarded
,
temporaryReferences
,
})
const
actionResult
=
await
finalizeAndGenerateFlight
(
req
,
ctx
,
requestStore
,
{
actionResult
:
Promise
.
resolve
(
returnVal
),
// if the page was not revalidated, or if the action was forwarded from another worker, we can skip the rendering the flight tree
skipFlight
:
!
workStore
.
pathWasRevalidated
||
actionWasForwarded
,
temporaryReferences
,
}
)
return
{
type
:
'done'
,
result
:
actionResult
,
formState
:
undefined
,
}
}
)
return
{
type
:
'done'
,
result
:
actionResult
,
formState
,
}
}
catch
(
err
)
{
if
(
err
instanceof
ActionNotFoundError
)
{
console
.
error
(
err
)
...
...
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