Skip to content

Commit

Permalink
fix(abci): invalid error returned when Codec terminates
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Nov 28, 2024
1 parent 697e86f commit b178ca8
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions abci/src/server/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<L: AsyncRead + AsyncWrite + Unpin>(
mut codec: Framed<L, Coder>,
request_tx: Sender<proto::abci::Request>,
Expand Down Expand Up @@ -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()
})
}
}

Expand Down

0 comments on commit b178ca8

Please sign in to comment.