From e85134fd65e717da1238355b4f97ee40f81e686b Mon Sep 17 00:00:00 2001 From: dfawley Date: Tue, 10 Jul 2018 15:56:11 -0700 Subject: [PATCH] transport: double-check deadline when processing server cancelation (#2211) --- transport/http2_client.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/transport/http2_client.go b/transport/http2_client.go index 3f11089a..05dfb9b0 100644 --- a/transport/http2_client.go +++ b/transport/http2_client.go @@ -948,6 +948,13 @@ func (t *http2Client) handleRSTStream(f *http2.RSTStreamFrame) { warningf("transport: http2Client.handleRSTStream found no mapped gRPC status for the received http2 error %v", f.ErrCode) statusCode = codes.Unknown } + if statusCode == codes.Canceled { + // Our deadline was already exceeded, and that was likely the cause of + // this cancelation. Alter the status code accordingly. + if d, ok := s.ctx.Deadline(); ok && d.After(time.Now()) { + statusCode = codes.DeadlineExceeded + } + } t.closeStream(s, io.EOF, false, http2.ErrCodeNo, status.Newf(statusCode, "stream terminated by RST_STREAM with error code: %v", f.ErrCode), nil, false) }