From cccf0d66d49df3076cb082fe7bd10447bf3d092b Mon Sep 17 00:00:00 2001 From: Niko Date: Sat, 6 May 2023 23:53:00 +0300 Subject: [PATCH] fix actor's stream response --- p2p-net/src/actor.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/p2p-net/src/actor.rs b/p2p-net/src/actor.rs index 7de7188..58065a9 100644 --- a/p2p-net/src/actor.rs +++ b/p2p-net/src/actor.rs @@ -120,7 +120,12 @@ impl< if bm.result() == ProtocolError::PartialContent.into() && TypeId::of::() != TypeId::of::<()>() { - let (b_sender, b_receiver) = mpsc::unbounded::(); + let (mut b_sender, b_receiver) = mpsc::unbounded::(); + let response = msg.try_into().map_err(|e| ProtocolError::ActorError)?; + b_sender + .send(response) + .await + .map_err(|err| ProtocolError::IoError)?; async fn pump_stream>( mut actor_receiver: Receiver, mut sos_sender: Sender, @@ -140,7 +145,9 @@ impl< // TODO deal with errors. break; } - sos_sender.send(response.unwrap()).await; + if sos_sender.send(response.unwrap()).await.is_err() { + break; + } } else { // todo deal with error (not a brokermessage) break;