-
-
Notifications
You must be signed in to change notification settings - Fork 936
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 backoff
option to pagination
#1182
Conversation
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.
This needs tests
Yep, definitely. That why I mentioned in the description that I had no clever idea how to test it 😉 Any idea how we could simulate this? |
Faketimers (lolex) |
@szmarczak yeah, I saw that you used it in other tests as well but I couldn't really figure out how to properly use it in this case. |
backoff
option to pagination
Actually do we need a |
Retry means that we accept running into potential server errors whereas backoff would allow us to prevent server errors from the beginning if you know the rate limits. |
I was just about to give the tests another try but after installing all dependencies and run
Is there anything wrong on master at the moment? |
Looks like you're missing |
Not really I think... I even removed the |
What about if you use |
Hm, honestly I have no clue how that test system works... I would have assumed that it would work with my current approach but then again I am running into typing issues (i.e. |
No worries, I'll fix it. |
@szmarczak thanks! I'm curious how you will do it 😊 I couldn't even see that my test was executed. Is there actually a simple way to run a single test (if I use only I see lint issues) in watch mode? And is it also somehow possible to log some stuff in between for debugging? |
@jaulz Bump :) |
@sindresorhus yeah, I would still love to see this as part of the package but unfortunately I was stuck with the test set up 😞 @szmarczak could you by any chance find some time and fix the test? |
I'll do this today. I'm not home rn, will be in two/three hours. |
After 30+ minutes of trying to introduce |
@szmarczak thanks a lot! |
No problem, sorry I hadn't got to this before. |
This PR adds an easy possibility to respect rate limits that are enforced by some APIs. If the rate limit is 600 per hour and you know that you will most likely hit the limit you can set
backoff
to100
which means that paginated requests are triggered only every 100 milliseconds. Unfortunately, I had no clever idea how to implement a test but maybe you have an idea?Checklist