Skip to content

Commit

Permalink
Retry on HTTP/2 internal errors. (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething committed Nov 7, 2023
1 parent 39cdba9 commit 2036ebb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions godo.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ func New(httpClient *http.Client, opts ...ClientOpt) (*Client, error) {
return resp, err
}

retryableClient.CheckRetry = func(ctx context.Context, resp *http.Response, err error) (bool, error) {
// In addition to the default retry policy, we also retry HTTP/2 INTERNAL_ERROR errors.
// See: https://github.com/golang/go/issues/51323
if err != nil && strings.Contains(err.Error(), "INTERNAL_ERROR") && strings.Contains(reflect.TypeOf(err).String(), "http2") {
return true, nil
}

return retryablehttp.DefaultRetryPolicy(ctx, resp, err)
}

var source *oauth2.Transport
if _, ok := c.HTTPClient.Transport.(*oauth2.Transport); ok {
source = c.HTTPClient.Transport.(*oauth2.Transport)
Expand Down

0 comments on commit 2036ebb

Please sign in to comment.