Skip to content

Commit 62dac6f

Browse files
authored
fix: prevent ScopedFuture stopping owner cleanup (#3863)
1 parent b36dec8 commit 62dac6f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

reactive_graph/src/computed/async_derived/arc_async_derived.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ impl<T: 'static> ArcAsyncDerived<T> {
560560
};
561561
let initial_value = SendOption::new_local(initial_value);
562562
let (this, _) = spawn_derived!(
563-
crate::spawn_local_scoped,
563+
crate::spawn_local,
564564
initial_value,
565565
fun,
566566
true,
@@ -595,7 +595,7 @@ impl<T: 'static> ArcAsyncDerived<T> {
595595
async move { SendOption::new_local(Some(fut.await)) }
596596
};
597597
let (this, _) = spawn_derived!(
598-
crate::spawn_local_scoped,
598+
crate::spawn_local,
599599
initial,
600600
fun,
601601
false,

reactive_graph/src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ pub fn spawn(task: impl Future<Output = ()> + Send + 'static) {
138138
any_spawner::Executor::spawn_local(task);
139139
}
140140

141+
/// Calls [`Executor::spawn_local`](any_spawner::Executor::spawn_local), but ensures that the task also runs in the current arena, if
142+
/// multithreaded arena sandboxing is enabled.
143+
pub fn spawn_local(task: impl Future<Output = ()> + 'static) {
144+
#[cfg(feature = "sandboxed-arenas")]
145+
let task = owner::Sandboxed::new(task);
146+
147+
any_spawner::Executor::spawn_local(task);
148+
}
149+
141150
/// Calls [`Executor::spawn_local`](any_spawner::Executor), but ensures that the task runs under the current reactive [`Owner`](crate::owner::Owner) and observer.
142151
///
143152
/// Does not cancel the task if the owner is cleaned up.

0 commit comments

Comments
 (0)