Skip to content

Commit

Permalink
calc delay: fix currentRetryAttempt mutation
Browse files Browse the repository at this point in the history
The mutation did not affect the code below.
This is for issue JustinBeckwith#122.

calc delay: prettier (format)
  • Loading branch information
jgehrcke committed Aug 16, 2021
1 parent a4173be commit 83f31bb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,12 @@ function onError(err: AxiosError) {
// Now it's certain that a retry is supposed to happen.
// Incremenent the counter, critical for linear and exp
// backoff delay calc.
(err.config as RaxConfig).raxConfig!.currentRetryAttempt! += 1;
config.currentRetryAttempt! += 1;

// Calculate delay according to chosen strategy
// Default to exponential backoff - formula: ((2^c - 1) / 2) * 1000
if (delay === 0) { // was not set by Retry-After logic
if (delay === 0) {
// was not set by Retry-After logic
if (config.backoffType === 'linear') {
// The delay between the first (actual) attempt and the
// first retry should be non-zero. That is, by definition
Expand Down

0 comments on commit 83f31bb

Please sign in to comment.