licensed-ci icon indicating copy to clipboard operation
licensed-ci copied to clipboard

Handle rate limiting responses when querying the GitHub API

Open jonabc opened this issue 3 years ago • 0 comments

Licensed-ci makes a few API calls during it's execution to find and post on issues and PRs. It's possible for GitHub's API to respond with a rate limiting error, in which case the best thing for this action to do is to implement a backoff and/or retry strategy. From the documentation, it looks like the API will return a 403 error for rate limits.

There are two types of rate limits

  1. primary - this is the basic X requests per hour type of limit, and the response will include headers giving the time that the limits will be reset. A retry strategy waiting until the reset time should work, though it would make sense to still throw an error if the user would have to wait more than a minute of two. In that case the error message should be very clear with something like This action is rate limited until <time>, please rerun the action after that time.

  2. secondary - this is burst detection, X requests per second or similar. I think licensed could only detect this based on the error message, but I'll take a look and see what information is available when this rate limit is triggered. A retry strategy using some randomness to wait X number of seconds should mean help spread out requests and avoid sending consistent request bursts.

cc @hendrikvanantwerpen

jonabc avatar Sep 29 '22 16:09 jonabc