Skip to content

Commit

Permalink
Merge branch 'rtrox-fixes' into context_retry
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrox committed Dec 29, 2022
2 parents a299ace + 4427c21 commit b68878a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions spotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,15 @@ func (c *Client) execute(req *http.Request, result interface{}, needsStatus ...i
}
defer resp.Body.Close()

if c.autoRetry && shouldRetry(resp.StatusCode) {
if c.autoRetry &&
isFailure(resp.StatusCode, needsStatus) &&
shouldRetry(resp.StatusCode) {
select {
case <-req.Context().Done():
// If the context is cancelled, return the original error
case <-time.After(retryDuration(resp)):
continue
}
}
}
if resp.StatusCode == http.StatusNoContent {
return nil
Expand Down

0 comments on commit b68878a

Please sign in to comment.