Skip to content

Commit

Permalink
fix: occasional use-after-disposed panic in Suspense
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Feb 12, 2025
1 parent 7be6a9d commit 620a14c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions leptos/src/suspense_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,13 @@ where
let eff = reactive_graph::effect::Effect::new_isomorphic({
move |_| {
tasks.track();
if tasks.read().is_empty() {
if let Some(tx) = tasks_tx.take() {
// If the receiver has dropped, it means the ScopedFuture has already
// dropped, so it doesn't matter if we manage to send this.
_ = tx.send(());
if let Some(tasks) = tasks.try_read() {
if tasks.is_empty() {
if let Some(tx) = tasks_tx.take() {
// If the receiver has dropped, it means the ScopedFuture has already
// dropped, so it doesn't matter if we manage to send this.
_ = tx.send(());
}
}
}
}
Expand Down

0 comments on commit 620a14c

Please sign in to comment.