Got: Upper limit on the retry backoff

Created on 8 Feb 2021  Â·  2Comments  Â·  Source: sindresorhus/got

What problem are you trying to solve?

Currently there is no upper limit on the backoff, meaning it grows exponentially if you want many retries which is not something you might want.

Describe the feature

So I would add a new optional parameter to the retry object called backoffLimit that would be a number of milliseconds to wait maximum between retries. This would basically do a Math.min between the default calculated backoff value and this parameter value. This would allow a user to put a limit of say 10 and have the following behaviour:

| Retry | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|-------|----|----|----|-----|-----|-----|-----|-----|-----|-----|
| Time | 2s | 4s | 8s | 16s | 32s | 60s | 60s | 60s | 60s | 60s |

Checklist

  • [x] I have read the documentation and made sure this feature doesn't already exist.
enhancement good for beginner ✭ help wanted ✭

Most helpful comment

Sounds ok to me, but I'll let other maintainers chime in too.

For now, you could provide your own calculateDelay function to achieve this.

All 2 comments

Sounds ok to me, but I'll let other maintainers chime in too.

For now, you could provide your own calculateDelay function to achieve this.

Thanks! I know I can provide the method, but I didn't want to lose the checks it does for the header and there was no easy way to import the default calculate delay method.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jamestalmage picture jamestalmage  Â·  3Comments

carvallegro picture carvallegro  Â·  4Comments

khizarsonu picture khizarsonu  Â·  3Comments

tkoelpin picture tkoelpin  Â·  3Comments

alvis picture alvis  Â·  3Comments