Skip to content

Commit

Permalink
Add retryNumber as a parameter of delay function (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
matiaslcoulougian authored Nov 18, 2024
1 parent 221089d commit d784146
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {Logger} from 'pino';

import {wrapApiError} from './errors';

type DelayFunction = (error: AxiosError<unknown, any>) => number;
type DelayFunction = (
error: AxiosError<unknown, any>,
retryNumber?: number
) => number;

export const DEFAULT_RETRIES = 3;
export const DEFAULT_RETRY_DELAY = 1000;
Expand Down Expand Up @@ -65,7 +68,7 @@ export function makeAxiosInstanceWithRetry(
if (typeof delay === 'number') {
return retryNumber * delay;
}
return delay(error);
return delay(error, retryNumber);

},
shouldResetTimeout: true,
Expand Down

0 comments on commit d784146

Please sign in to comment.