diff --git a/stream.go b/stream.go index 89e4ec8a..591d21b5 100644 --- a/stream.go +++ b/stream.go @@ -183,14 +183,18 @@ func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth cs.t = t cs.s = s cs.p = &parser{r: s} - // Listen on ctx.Done() to detect cancellation when there is no pending - // I/O operations on this stream. + // Listen on ctx.Done() to detect cancellation and s.Done() to detect normal termination + // when there is no pending I/O operations on this stream. go func() { select { case <-t.Error(): // Incur transport error, simply exit. case <-s.Done(): - cs.finish(err) + if s.StatusCode() == codes.OK { + cs.finish(nil) + } else { + cs.finish(Errorf(s.StatusCode(), "%s", s.StatusDesc())) + } cs.closeTransportStream(nil) case <-s.Context().Done(): err := s.Context().Err() diff --git a/transport/http2_client.go b/transport/http2_client.go index 3a0fdac0..457536e9 100644 --- a/transport/http2_client.go +++ b/transport/http2_client.go @@ -692,7 +692,6 @@ func (t *http2Client) handleRSTStream(f *http2.RSTStreamFrame) { grpclog.Println("transport: http2Client.handleRSTStream found no mapped gRPC status for the received http2 error ", f.ErrCode) s.statusCode = codes.Unknown } - //grpclog.Println("DEBUG handleRSTStram: ", f, " | ", f.ErrCode) close(s.done) s.mu.Unlock() s.write(recvMsg{err: io.EOF})