You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
The text was updated successfully, but these errors were encountered:
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
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:
The text was updated successfully, but these errors were encountered: