-
Notifications
You must be signed in to change notification settings - Fork 24
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
handle GitHub API rate limits
#4298
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.
Nice!
Just some minor things on the secondary limit.
if resp.Header.Get("x-ratelimit-remaining") == "0" { | ||
unix, err := strconv.ParseInt(resp.Header.Get("x-ratelimit-reset"), 10, 64) // x-ratelimit-reset - The time at which the current rate limit window resets, in UTC epoch seconds | ||
if err != nil { // Must be impossible to hit errors here, but just in case | ||
return time.Second * 8 // Github starts with 8s jailtime |
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.
Where did you find this? I only found a one minute pause on the secondary limit.
Do we need to handle primary and secondary separately?
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.
Couldn't find at this point.
What would you suggest for error handling?
I don't think so, no, it'll be reflected in wait time. But, I think we could add the maximum wait time and throw error after that, because otherwise the scan can be stuck up to an hour and provide no data
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.
Ok, I understood your comment in a way that it is some default GitHub setting.
I like the idea with the max wait time.
based on: https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit