Skip to content

Commit

Permalink
remove the need for unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienDeepgram committed Jul 25, 2024
1 parent 149cb74 commit f251852
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/listen/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ impl<'a> StreamRequestBuilder<'a, Receiver<Result<Bytes>>, 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);
Expand Down

0 comments on commit f251852

Please sign in to comment.