Skip to content

Commit 313abb2

Browse files
committed
Fix respons stream to only return a single error.
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.
1 parent df1c8df commit 313abb2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tonic/src/codec/decode.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ impl StreamingInner {
285285
if let Direction::Response(status) = self.direction {
286286
if let Err(e) = crate::status::infer_grpc_status(self.trailers.as_ref(), status) {
287287
if let Some(e) = e {
288+
// If the trailers contain a grpc-status, then we should return that as the error
289+
// and otherwise stop the stream (by taking the error state)
290+
self.trailers.take();
288291
return Err(e);
289292
}
290293
}

0 commit comments

Comments
 (0)