softonic / axios-retry

Axios plugin that intercepts failed requests and retries them whenever possible
Other
1.89k stars 167 forks source link

It looks like the onMaxRetryTimesExceeded function is not triggered #282

Open hoekstrajan opened 4 months ago

hoekstrajan commented 4 months ago

I have implemented axios-retry which works very well for retrying a API endpoint in my Vue application if for instance the accessToken is expired and a new one is requested. I'm trying this 5 times, before triggering the onMaxRetryTimesExceededHandler in my code. But somehow this function is not triggered. What am i doing wrong:

axiosRetry(axiosInstance, {
    retries: 5,
    retryDelay: axiosRetry.exponentialDelay,
    retryCondition: retryConditionHandler,
    onMaxRetryTimesExceeded: onMaxRetryTimesExceededHandler,
    onRetry: onRetryHandler,
})

function onMaxRetryTimesExceededHandler(_error: AxiosError<unknown, any>, _count: number) {
    console.log('onMaxRetryTimesExceededHandler')
    forceLogout()
}
obscurecat64 commented 4 months ago

@hoekstrajan could it be that you have a timeout set and exceeded the timeout?

if so you could try:

axiosInstance.defaults.timeout = 20000;