From f251852091bb1c8a87f888f03615b6aebcf3694a Mon Sep 17 00:00:00 2001 From: Damien Murphy Date: Wed, 24 Jul 2024 18:26:39 -0700 Subject: [PATCH] remove the need for unwrap --- src/listen/websocket.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/listen/websocket.rs b/src/listen/websocket.rs index 0a4dc094..64584332 100644 --- a/src/listen/websocket.rs +++ b/src/listen/websocket.rs @@ -221,9 +221,11 @@ impl<'a> StreamRequestBuilder<'a, Receiver>, DeepgramError> { let task = async move { while let Some(frame) = chunker.next().await { tokio::time::sleep(frame_delay).await; - // This unwrap() is safe because application logic dictates that the Receiver won't - // be dropped before the Sender. - tx.send(frame).await.unwrap(); + if let Err(e) = tx.send(frame).await { + eprintln!("Failed to send frame: {:?}", e); + // TODO Handle the error, e.g., break the loop, retry, or log the error + break; + } } }; tokio::spawn(task);