Skip to content

Commit

Permalink
Merge pull request #1043 from jacobbednarz/better-rate-limit-retry-ex…
Browse files Browse the repository at this point in the history
…ceeded-error

cloudflare: update rate limit exceeded error message
  • Loading branch information
jacobbednarz authored Aug 15, 2022
2 parents 9671d2c + 649e56d commit 63b6ab8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/1043.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
cloudflare: make it clear when the rate limit retries have been exhausted
```
4 changes: 4 additions & 0 deletions cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ func (api *API) makeRequestWithAuthTypeAndHeaders(ctx context.Context, method, u
// retry if the server is rate limiting us or if it failed
// assumes server operations are rolled back on failure
if respErr != nil || resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode >= 500 {
if resp.StatusCode == http.StatusTooManyRequests {
respErr = errors.New("exceeded available rate limit retries")
}

// if we got a valid http response, try to read body so we can reuse the connection
// see https://golang.org/pkg/net/http/#Client.Do
if respErr == nil {
Expand Down

0 comments on commit 63b6ab8

Please sign in to comment.