Skip to content

Commit

Permalink
internal/transport: do not mask ConnectionError
Browse files Browse the repository at this point in the history
PR grpc#4316 updates the http2Client `Close` method so it can append
additional debug information about prior GOAWAY messages before this
connection was closed.

However, it is not safe to do this in the general case, as the original
error is propagated through the connection's `Stream` via a `recvMsg`,
and read later on. If the additional metadata is appended by wrapping
the error with `fmt.Errorf`, downstream clients will not be able to
detect meaningful error conditions (such as `io.EOF`) or the temporarity
of the error.

Fix this by properly wrapping the original error with `connectionErrorf`
like it is done for all the other errors in the client.
  • Loading branch information
vmg committed Jun 22, 2021
1 parent 50328cf commit 2650a2f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/transport/http2_client.go
Expand Up @@ -878,7 +878,13 @@ func (t *http2Client) Close(err error) {
// for understanding the root cause for this connection to be closed.
_, goAwayDebugMessage := t.GetGoAwayReason()
if len(goAwayDebugMessage) > 0 {
err = fmt.Errorf("closing transport due to: %v, received prior goaway: %v", err, goAwayDebugMessage)
tmpErr := true
originalErr := err
if ce, ok := err.(ConnectionError); ok {
tmpErr = ce.Temporary()
originalErr = ce.Origin()
}
err = connectionErrorf(tmpErr, originalErr, "closing transport due to: %v, received prior goaway: %v", originalErr, goAwayDebugMessage)
}
// Notify all active streams.
for _, s := range streams {
Expand Down

0 comments on commit 2650a2f

Please sign in to comment.