diff --git a/bindings_ffi/src/mls.rs b/bindings_ffi/src/mls.rs index 094749392..08b29551d 100644 --- a/bindings_ffi/src/mls.rs +++ b/bindings_ffi/src/mls.rs @@ -992,9 +992,12 @@ impl FfiStreamCloser { let handle = handle.take(); if let Some(h) = handle { h.abort(); - h.await.map_err(|_| GenericError::Generic { - err: "subscription event loop join error".into(), - })??; + let join_result = h.await; + if matches!(join_result, Err(ref e) if !e.is_cancelled()) { + return Err(GenericError::Generic { + err: format!("subscription event loop join error {}", join_result.unwrap_err()), + }) + } } else { log::warn!("subscription already closed"); } @@ -1139,9 +1142,7 @@ mod tests { log::info!("Received: {}", String::from_utf8_lossy(&message.content)); messages.push(message); let _ = self.num_messages.fetch_add(1, Ordering::SeqCst); - log::debug!("NOTIFYING"); self.notify.notify_one(); - log::debug!("NOTIFIED"); } } diff --git a/bindings_ffi/src/v2.rs b/bindings_ffi/src/v2.rs index c40bf23cc..5527a634c 100644 --- a/bindings_ffi/src/v2.rs +++ b/bindings_ffi/src/v2.rs @@ -312,9 +312,12 @@ impl FfiV2Subscription { let handle = handle.take(); if let Some(h) = handle { h.abort(); - h.await.map_err(|_| GenericError::Generic { - err: "subscription event loop join error".into(), - })?; + let join_result = h.await; + if matches!(join_result, Err(ref e) if !e.is_cancelled()) { + return Err(GenericError::Generic { + err: format!("subscription event loop join error {}", join_result.unwrap_err()), + }) + } } Ok(()) } diff --git a/xmtp_mls/src/subscriptions.rs b/xmtp_mls/src/subscriptions.rs index ec9cbafe4..085b81245 100644 --- a/xmtp_mls/src/subscriptions.rs +++ b/xmtp_mls/src/subscriptions.rs @@ -487,10 +487,11 @@ mod tests { let messages = messages.lock().unwrap(); assert_eq!(messages.len(), 5); } - - handle.abort(); - tokio::time::sleep(std::time::Duration::from_millis(50)).await; - assert!(handle.is_finished()); + + let a = handle.abort_handle(); + a.abort(); + handle.await.unwrap(); + assert!(a.is_finished()); alix_group .send_message("first".as_bytes(), &alix)