Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(internal/gensupport): add net.ErrClosed to default retry #1462

Merged
merged 4 commits into from Mar 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions internal/gensupport/retry.go
Expand Up @@ -5,7 +5,10 @@
package gensupport

import (
"errors"
"io"
"net"
"strings"
"time"

"github.com/googleapis/gax-go/v2"
Expand Down Expand Up @@ -65,6 +68,14 @@ func shouldRetry(status int, err error) bool {
return true
}
}
var opErr *net.OpError
if errors.As(err, &opErr) {
if strings.Contains(opErr.Error(), "use of closed network connection") {
// TODO: check against net.ErrClosed (go 1.16+) instead of string
return true
}
}

// If Go 1.13 error unwrapping is available, use this to examine wrapped
// errors.
if err, ok := err.(interface{ Unwrap() error }); ok {
Expand Down