From b178ca83aa733bb6deb2eec340cf70656d8b1999 Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:12:27 +0100 Subject: [PATCH] fix(abci): invalid error returned when Codec terminates --- abci/src/server/codec.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/abci/src/server/codec.rs b/abci/src/server/codec.rs index 8996d71..dd38dc4 100644 --- a/abci/src/server/codec.rs +++ b/abci/src/server/codec.rs @@ -97,6 +97,18 @@ impl<'a> Codec { Self::process_worker_queues(codec, request_tx, response_rx, cancel).await; } + + /// Worker that moves messages between codec and requests and responses + /// queues. + /// + /// Reads messages from ABCI Client from `codec`, sends them to Tenderdash + /// via `request_tx`, receives Tenderdash responses from `response_rx` + /// and forwards to + /// + /// ## Error handling + /// + /// On error, it cancels the `cancel` [CancellationToken] and exits. + /// It causes `response_rx` to be closed. async fn process_worker_queues( mut codec: Framed, request_tx: Sender, @@ -149,9 +161,10 @@ impl<'a> Codec { } pub fn send(&self, value: Response) -> Result<(), Error> { - self.response_tx - .blocking_send(value) - .map_err(|e| Error::Async(e.to_string())) + self.response_tx.blocking_send(value).map_err(|_| { + // channel closed, `process_worker_queues` either errored or cancelled + Error::Cancelled() + }) } }