Skip to content

Commit

Permalink
fix(ui): Shutdown the child tasks if the channel got closed in the su…
Browse files Browse the repository at this point in the history
…pervisor
  • Loading branch information
poljar committed Jan 16, 2025
1 parent a020db3 commit 766cb99
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions crates/matrix-sdk-ui/src/sync_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,13 @@ impl SyncTaskSupervisor {
let state = inner.state.clone();

async move {
let Some(report) = receiver.recv().await else {
let report = if let Some(report) = receiver.recv().await {
report
} else {
info!("internal channel has been closed?");
return;
// We should still stop the child tasks in the unlikely scenario that our
// receiver died.
TerminationReport::supervisor_error()
};

// If one service failed, make sure to request stopping the other one.
Expand Down Expand Up @@ -417,6 +421,16 @@ struct TerminationReport {
origin: TerminationOrigin,
}

impl TerminationReport {
fn supervisor_error() -> Self {
TerminationReport {
is_error: true,
has_expired: false,
origin: TerminationOrigin::Supervisor,
}
}
}

// Testing helpers, mostly.
#[doc(hidden)]
impl SyncService {
Expand Down

0 comments on commit 766cb99

Please sign in to comment.