Skip to content

Commit

Permalink
Fix respons stream to only return a single error.
Browse files Browse the repository at this point in the history
According to [#689](#689) streams should end after the first error. Therefore, when we find an error in the response step, discard the trailers so that the stream ends.
  • Loading branch information
alexrudy committed Apr 16, 2024
1 parent 16608ea commit 3c013ea
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tonic/src/codec/decode.rs
Expand Up @@ -285,6 +285,9 @@ impl StreamingInner {
if let Direction::Response(status) = self.direction {
if let Err(e) = crate::status::infer_grpc_status(self.trailers.as_ref(), status) {
if let Some(e) = e {
// If the trailers contain a grpc-status, then we should return that as the error
// and otherwise stop the stream (by taking the error state)
self.trailers.take();
return Err(e);
}
}
Expand Down

0 comments on commit 3c013ea

Please sign in to comment.