Closed Jokero closed 1 year ago
@mawrkus What do you think?
+1 also shouldResetTimeout
should be true
by default
I can also confirm this unexpected behavior - just spent a couple of hours debugging my application, until I noticed the request was just not sent, due to too low (1ms) timeout.
Documentation says:
My expectation: if request has timeout=7000, the whole request lifecycle should be ended after this time. If delay + passed time is greater than original timeout, we should not do a new retry.
Actual result with exponential delay:
Code
```js const http = require('http'); const axios = require('axios'); const axiosRetry = require('axios-retry'); let c = 0; const server = http.createServer((req, res) => { console.log('request #' + ++c); res.statusCode = 500; res.end(); }); server.listen(3333, () => { axiosRetry(axios, { retryDelay: axiosRetry.exponentialDelay, shouldResetTimeout: false, }); console.time('time passed'); axios.get('http://localhost:3333/ololo', { timeout: 7000, 'axios-retry': { retries: 7 } }).catch(err => { console.timeEnd('time passed') console.log('error', err.message); }); }); ```
The library calculated the latest
timeout=1ms
anddelay=6536ms
. It's obvious that there is no need to do this attempt as it will result in immediate request cancellation. I think that rejected promise with error should be returned if this expressionconfig.timeout - lastRequestDuration - delay
<= 0: