Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay for first retry always zero, no matter what retryDelay function... very strange. #293

Open
jeffreyhuey opened this issue Dec 20, 2024 · 0 comments

Comments

@jeffreyhuey
Copy link

jeffreyhuey commented Dec 20, 2024

I'm using axios-retry 4.5.0. It seems no matter what retryDelay I use, linear, exponentialDelay or custom delay, the delay for the first retry is always zero (it's retried immediately after a failed http request). Code like below. Wonder if anybody else experiencing this situation? Help will be much appreciated.
// Initialize axios-retry with the axios instance
axiosRetry(axios, {
retries: 3, // Number of retry attempts
retryDelay: (retryNumber) => {return Math.pow(2, retryNumber) * 2000 },
retryCondition: (error) => {
// Retry on network errors or 5xx status codes
return axiosRetry.isNetworkError(error) || axiosRetry.isRetryableError(error);
},
onRetry: (retryCount) => {
var now = new Date();
// Extract the current time
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
// Format the time as a string
var currentTime = ${hours}:${minutes}:${seconds};
console.log(currentTime + : retry attempt #${retryCount});
},
resetTimeout: true
});

Output of test program is like this:
22:13:6 : http get sent
22:13:6 : retry attempt #1 <----------------- First retry is immediate !!!
22:13:10 : retry attempt #2
22:13:18 : retry attempt #3
Error fetching data:

@jeffreyhuey jeffreyhuey changed the title Delay for first retry always zero Delay for first retry always zero, no matter what retryDelay function... very strange. Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant