-
-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add retry.backoffLimit option #454
Conversation
CI is failing |
Thanks for the review. I must say that testing the delay of the retries a bit hard. You probably also know this, because the delay wasn't initially tested anyway. |
Maybe check |
You also need to add the docs to the readme. |
The default backoff function is exponential, so after a couple of retries the delay will become very large. In case you are polling an api, you want at least that there is an upper limit to this delay, for example 1000ms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the tests to use the Node 14 Performance API (instead of LTS).
By the way, it would be nice if CI runs automatically on push. Now the feedback cycle is pretty slow.
@sholladay I'm aware, and I did for this repo. But I have 1000+ repos. I cannot do it manually on all of them. |
It looks like the new test that depends on timing makes the test suite flaky. I doubt whether it is a good idea to keep the test. Removing it altogether might be the right thing to do. |
@sindresorhus In the mean time there haven't been any activity for about a month. Any suggestions how to follow up? Changes needed or complete the PR? |
Thanks. Sorry for the delay. I must have missed the notification. |
This PR had flaky tests, so I increased the test timeout offsets. Maybe it is fixed in #484, so we could decrease (set to 0?) the allowedOffset. |
I saw in the source code that the retry backoff function is hardcoded and exponential. However, I wanted to customize it.
Fortunately I also found the open issue addressing this limitation.
To start simple, I added a
backoffLimit
so that you can cap the delay that is exponentially growing. After 5 or so retries the delay becomes so large that the user will give up anyway.Setting the limit to for example 1000 in combination with 60 retries will change the behavior into polling for 1 minute (my use case).
I had some trouble testing the delay because the calculate function is private and I didn't find a way to extract this information from the
ky
instance or response.So I did some perf measurements to test the delays.
If you are happy with the PR so far, I will implement the
calculateDelay
option too.Fixes #389