Skip to content

Commit

Permalink
transport: double-check deadline when processing server cancelation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley authored Jul 10, 2018
1 parent c491b25 commit e85134f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit e85134f

Please sign in to comment.