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
a986e173
Unverified
Commit
a986e173
authored
Oct 28, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Oct 28, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash when suspending in Components using `useActionQueue` (#85459)
parent
40672141
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
+26
-8
use-action-queue.ts
packages/next/src/client/components/use-action-queue.ts
+26
-8
No files found.
packages/next/src/client/components/use-action-queue.ts
View file @
a986e173
...
@@ -22,6 +22,12 @@ export function dispatchAppRouterAction(action: ReducerActions) {
...
@@ -22,6 +22,12 @@ export function dispatchAppRouterAction(action: ReducerActions) {
dispatch
(
action
)
dispatch
(
action
)
}
}
const
__DEV__
=
process
.
env
.
NODE_ENV
!==
'production'
const
promisesWithDebugInfo
:
WeakMap
<
Promise
<
AppRouterState
>
,
Promise
<
AppRouterState
>
&
{
_debugInfo
?:
Array
<
unknown
>
}
>
=
__DEV__
?
new
WeakMap
()
:
(
null
as
any
)
export
function
useActionQueue
(
export
function
useActionQueue
(
actionQueue
:
AppRouterActionQueue
actionQueue
:
AppRouterActionQueue
):
AppRouterState
{
):
AppRouterState
{
...
@@ -56,15 +62,27 @@ export function useActionQueue(
...
@@ -56,15 +62,27 @@ export function useActionQueue(
// passed to React (via `use`) so that the latency is accurately represented
// passed to React (via `use`) so that the latency is accurately represented
// in the React DevTools.
// in the React DevTools.
const
stateWithDebugInfo
=
useMemo
(()
=>
{
const
stateWithDebugInfo
=
useMemo
(()
=>
{
if
(
!
__DEV__
)
{
return
state
}
if
(
isThenable
(
state
))
{
if
(
isThenable
(
state
))
{
const
debugInfo
:
Array
<
unknown
>
=
[]
// useMemo can't be used to cache a Promise since the memoized value is thrown
const
promiseWithDebugInfo
=
Promise
.
resolve
(
state
).
then
((
asyncState
)
=>
{
// away when we suspend. So we use a WeakMap to cache the Promise with debug info.
if
(
asyncState
.
debugInfo
!==
null
)
{
let
promiseWithDebugInfo
=
promisesWithDebugInfo
.
get
(
state
)
debugInfo
.
push
(...
asyncState
.
debugInfo
)
if
(
promiseWithDebugInfo
===
undefined
)
{
}
const
debugInfo
:
Array
<
unknown
>
=
[]
return
asyncState
promiseWithDebugInfo
=
Promise
.
resolve
(
state
).
then
((
asyncState
)
=>
{
})
as
Promise
<
AppRouterState
>
&
{
_debugInfo
?:
Array
<
unknown
>
}
if
(
asyncState
.
debugInfo
!==
null
)
{
promiseWithDebugInfo
.
_debugInfo
=
debugInfo
debugInfo
.
push
(...
asyncState
.
debugInfo
)
}
return
asyncState
})
as
Promise
<
AppRouterState
>
&
{
_debugInfo
?:
Array
<
unknown
>
}
promiseWithDebugInfo
.
_debugInfo
=
debugInfo
promisesWithDebugInfo
.
set
(
state
,
promiseWithDebugInfo
)
}
return
promiseWithDebugInfo
return
promiseWithDebugInfo
}
}
return
state
return
state
...
...
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