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
ba45fac7
Unverified
Commit
ba45fac7
authored
Aug 20, 2026
by
vercel-fleet-prod[bot]
Committed by
GitHub
Aug 20, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: guard completed join futures
Co-authored-by:
Tobias Koppers
<
1365881+sokra@users.noreply.github.com
>
parent
e7f1bf74
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
7 deletions
+50
-7
join_iter_ext.rs
turbopack/crates/turbo-tasks/src/join_iter_ext.rs
+50
-7
No files found.
turbopack/crates/turbo-tasks/src/join_iter_ext.rs
View file @
ba45fac7
...
@@ -75,14 +75,14 @@ impl ArcWake for WakeTask {
...
@@ -75,14 +75,14 @@ impl ArcWake for WakeTask {
let
Some
(
shared
)
=
task
.shared
.upgrade
()
else
{
let
Some
(
shared
)
=
task
.shared
.upgrade
()
else
{
return
;
return
;
};
};
shared
.queue
.lock
()
.unwrap
()
.push
(
Arc
::
downgrad
e
(
task
));
shared
.queue
.lock
()
.unwrap
()
.push
(
Arc
::
clon
e
(
task
));
shared
.parent
.wake
();
shared
.parent
.wake
();
}
}
}
}
#[derive(Default)]
#[derive(Default)]
struct
WakeShared
{
struct
WakeShared
{
queue
:
Mutex
<
Vec
<
Weak
<
WakeTask
>>>
,
queue
:
Mutex
<
Vec
<
Arc
<
WakeTask
>>>
,
parent
:
AtomicWaker
,
parent
:
AtomicWaker
,
}
}
...
@@ -231,24 +231,28 @@ where
...
@@ -231,24 +231,28 @@ where
// observes the old queued item (which this poll handles) or waits for the lock
// observes the old queued item (which this poll handles) or waits for the lock
// and appends a new item; it cannot be lost between those operations.
// and appends a new item; it cannot be lost between those operations.
let
queued
=
mem
::
take
(
&
mut
*
queue
);
let
queued
=
mem
::
take
(
&
mut
*
queue
);
for
task
in
&
queued
{
task
.queued
.store
(
false
,
Ordering
::
Release
);
}
queued
queued
.into_iter
()
.filter_map
(|
task
|
task
.upgrade
())
.inspect
(|
task
|
task
.queued
.store
(
false
,
Ordering
::
Release
))
.collect
::
<
Vec
<
_
>>
()
};
};
for
task
in
ready
{
for
task
in
ready
{
let
wake_tasks
=
this
.wake_tasks
.as_mut
()
.unwrap
();
if
wake_tasks
[
task
.index
]
.is_none
()
{
continue
;
}
let
mut
elem
=
get_pin_mut
(
this
.elems
.as_mut
(),
task
.index
);
let
mut
elem
=
get_pin_mut
(
this
.elems
.as_mut
(),
task
.index
);
let
elem
=
elem
.as_mut
()
.project
();
let
elem
=
elem
.as_mut
()
.project
();
if
elem
.output
.is_some
()
{
if
elem
.output
.is_some
()
{
wake_tasks
[
task
.index
]
=
None
;
continue
;
continue
;
}
}
let
waker
=
waker_ref
(
&
task
);
let
waker
=
waker_ref
(
&
task
);
let
mut
child_cx
=
Context
::
from_waker
(
&
waker
);
let
mut
child_cx
=
Context
::
from_waker
(
&
waker
);
if
let
Poll
::
Ready
(
output
)
=
elem
.future
.poll
(
&
mut
child_cx
)
{
if
let
Poll
::
Ready
(
output
)
=
elem
.future
.poll
(
&
mut
child_cx
)
{
*
elem
.output
=
Some
(
output
);
*
elem
.output
=
Some
(
output
);
this
.wake_tasks
.as_mut
()
.unwrap
()
[
task
.index
]
=
None
;
wake_tasks
[
task
.index
]
=
None
;
this
.pending
-
=
1
;
this
.pending
-
=
1
;
}
}
}
}
...
@@ -451,6 +455,29 @@ mod tests {
...
@@ -451,6 +455,29 @@ mod tests {
started
:
bool
,
started
:
bool
,
}
}
struct
WakeWhenReady
{
value
:
usize
,
polls
:
usize
,
ready_after
:
usize
,
completed
:
bool
,
}
impl
Future
for
WakeWhenReady
{
type
Output
=
Result
<
usize
>
;
fn
poll
(
mut
self
:
Pin
<&
mut
Self
>
,
cx
:
&
mut
Context
<
'_
>
)
->
Poll
<
Self
::
Output
>
{
assert
!
(
!
self
.completed
,
"future polled after completion"
);
self
.polls
+=
1
;
cx
.waker
()
.wake_by_ref
();
if
self
.polls
==
self
.ready_after
{
self
.completed
=
true
;
Poll
::
Ready
(
Ok
(
self
.value
))
}
else
{
Poll
::
Pending
}
}
}
impl
Future
for
ThreadWake
{
impl
Future
for
ThreadWake
{
type
Output
=
Result
<
usize
>
;
type
Output
=
Result
<
usize
>
;
...
@@ -546,6 +573,22 @@ mod tests {
...
@@ -546,6 +573,22 @@ mod tests {
assert_eq!
(
error
.to_string
(),
"first"
);
assert_eq!
(
error
.to_string
(),
"first"
);
}
}
#[test]
fn
completed_futures_queued_by_a_racing_wake_are_not_polled_again
()
{
let
values
=
block_on
(
(
0
..
31
)
.map
(|
value
|
WakeWhenReady
{
value
,
polls
:
0
,
ready_after
:
if
value
==
30
{
3
}
else
{
2
},
completed
:
false
,
})
.try_join
(),
)
.unwrap
();
assert_eq!
(
values
,
(
0
..
31
)
.collect
::
<
Vec
<
_
>>
());
}
#[test]
#[test]
fn
wake_from_another_thread_is_supported
()
{
fn
wake_from_another_thread_is_supported
()
{
let
values
=
block_on
(
let
values
=
block_on
(
...
...
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