We also use retry-axios in one project and we have support there (through a patch) to set a linear or static backoff type and value.
Would be great to have it configurable from the client / request side in the options too.
https://github.com/sindresorhus/ky/blob/78814e74efaaab65728103a13541820441b05d93/index.js#L337-L338
What's the reason you want to use a linear or static interval? Exponential is widely adopted and is important in most circumstances. I've seen engineers shoot themselves in the foot like this. Your server is a bit overloaded, responses start failing, the clients begin hammering the server with retries, and you end up DOSing yourself. You can avoid that by doing exponential backoff, which guarantee that the pressure will eventually be relieved and the system will recover.
As for the API, if we wanted to implement this, it would probably be a function option, where the function returns the number of milliseconds to delay until retry. Its arguments could be the error thrown by the previous request attempt, the retry count, and maybe also the request object.
There is a lot of overlap here with the beforeRetry hook option. Those hooks receive the arguments I mentioned and they are allowed to stop the retry from happening, but they don't currently have the ability to override the delay. In fact, they run _after_ the delay. We could potentially change that, though.
We are caching requests on the server side which are passed through to another service. In our case the connection was working on the second try - it's a SOAP request which is run only once. I am aware of the drawbacks of a linear or static values but exponential is not what we need here. Or with a slightly different and lower value as the calculation is hardcoded for now.
I'm fine with adding support for users to do their own delay calculations. We could do what Got does and add a calculateDelay property to the retry option: https://github.com/sindresorhus/got#retry
However, the docs for it should warn against using linear/static delay and link to some reading material about it.
That sounds good.
Most helpful comment
I'm fine with adding support for users to do their own delay calculations. We could do what Got does and add a
calculateDelayproperty to theretryoption: https://github.com/sindresorhus/got#retryHowever, the docs for it should warn against using linear/static delay and link to some reading material about it.