From 6e4682b8de2052de014d548b9c3947403970386d Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Sat, 13 Apr 2024 16:25:20 +0000 Subject: [PATCH] Do not discard trailers when checking streaming response status --- tonic/src/codec/decode.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tonic/src/codec/decode.rs b/tonic/src/codec/decode.rs index 5ebe50d96..8cba8ba88 100644 --- a/tonic/src/codec/decode.rs +++ b/tonic/src/codec/decode.rs @@ -283,11 +283,9 @@ impl StreamingInner { fn response(&mut self) -> Result<(), Status> { if let Direction::Response(status) = self.direction { - if let Some(trailers) = self.trailers.take() { - if let Err(e) = crate::status::infer_grpc_status(Some(&trailers), status) { - if let Some(e) = e { - return Err(e); - } + if let Err(e) = crate::status::infer_grpc_status(self.trailers.as_ref(), status) { + if let Some(e) = e { + return Err(e); } } } @@ -390,9 +388,6 @@ impl Stream for Streaming { return Poll::Ready(None); } - // FIXME: implement the ability to poll trailers when we _know_ that - // the consumer of this stream will only poll for the first message. - // This means we skip the poll_trailers step. if let Some(item) = self.decode_chunk()? { return Poll::Ready(Some(Ok(item))); }