-
-
Notifications
You must be signed in to change notification settings - Fork 444
Closed
Description
Thanks for creating ky! I used it extensively in my libraries and projects.
I'm running into an issue where I'm making a lot of calls in parallel to an API with a rate limit and the 429 retries are all happening at the same time and triggering the rate limit again. I've tested with a forked version of Ky and adding a random jitter to the retry time makes things much better.
I'm happy to contribute a PR, but wanted to see which, if any, solutions you are open to:
- Add a random jitter (and potentially a way to control it) to the retry calculation here
- Allow passing a custom function to replace
BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000 - Make it possible to do this from the
beforeRetryhook?
For more context, what I tested was calculating a jitter factor like JITTER_FACTOR * randomBetween(1, -1) and then multiplying the existing retry time by that. It could be configured so that the default value is 1, so there is no change to existing retry time calculation.
transitive-bullshit and domwebber
Metadata
Metadata
Assignees
Labels
No labels