Skip to content

Commit 5093f28

Browse files
fix: allow canceling a request while it is waiting to retry
1 parent 78e159d commit 5093f28

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/requestconfig/requestconfig.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,11 @@ func (cfg *RequestConfig) Execute() (err error) {
470470
res.Body.Close()
471471
}
472472

473-
time.Sleep(retryDelay(res, retryCount))
473+
select {
474+
case <-ctx.Done():
475+
return ctx.Err()
476+
case <-time.After(retryDelay(res, retryCount)):
477+
}
474478
}
475479

476480
// Save *http.Response if it is requested to, even if there was an error making the request. This is

0 commit comments

Comments
 (0)