diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/swarm/changes.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/swarm/changes.rs b/src/swarm/changes.rs index 0f22f52..a04ce7d 100644 --- a/src/swarm/changes.rs +++ b/src/swarm/changes.rs @@ -22,7 +22,7 @@ pub(crate) async fn run_change_publisher(state: AppState) { let before = last_heads.clone(); let doc = Arc::clone(&state.doc); - let (heads, paths, conflicts) = tokio::task::spawn_blocking(move || { + let looked = tokio::task::spawn_blocking(move || { let replica = doc.blocking_read(); let heads = replica.heads().to_vec(); if heads == before { @@ -45,8 +45,13 @@ pub(crate) async fn run_change_publisher(state: AppState) { } (heads, paths, conflicts) }) - .await - .expect("change publisher task panicked"); + .await; + let (heads, paths, conflicts) = match looked { + Ok(looked) => looked, + // The runtime is shutting down (the node stops): nothing to publish to. + Err(error) if error.is_cancelled() => return, + Err(error) => std::panic::resume_unwind(error.into_panic()), + }; if heads == last_heads { continue; |
