peter-murray / inactive-users-action

GitHub Action for generating a report on user activity in a GitHub Enterprise Organization.
MIT License
70 stars 32 forks source link

Action bounces on API limits #1

Closed AndreasPrang closed 3 years ago

AndreasPrang commented 4 years ago

For us the action fails because of API limits.

LOG

Building repository activity for: spring-media/bscmp-evaluation-next-suspense... 198 completed. 199 Building repository activity for: spring-media/rbbt-jenkins-slave-image... 200 Request quota exhausted for request GET https://api.github.com/repos/spring-media/rbbt-jenkins-slave-image/issues/comments?since=2020-07-03T00%3A00%3A00.000Z&per_page=100 201 RequestError [HttpError]: API rate limit exceeded for user ID 1097566. 202 at /home/runner/work/_actions/peter-murray/inactive-users-action/v1/dist/index.js:5929:23 203 at runMicrotasks () 204 at processTicksAndRejections (internal/process/task_queues.js:93:5) 205 at async Job.doExecute (/home/runner/work/_actions/peter-murray/inactive-users-action/v1/dist/index.js:8959:18) { 206 name: 'HttpError', 207 status: 403, 208 headers: { 209 'access-control-allow-origin': '*', 210 'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset', 211 connection: 'close', 212 'content-encoding': 'gzip', 213 'content-security-policy': "default-src 'none'", 214 'content-type': 'application/json; charset=utf-8', 215 date: 'Thu, 01 Oct 2020 14:27:29 GMT', 216 'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', 217 server: 'GitHub.com', 218 status: '403 Forbidden', 219 'strict-transport-security': 'max-age=31536000; includeSubdomains; preload', 220 'transfer-encoding': 'chunked', 221 vary: 'Accept-Encoding, Accept, X-Requested-With', 222 'x-accepted-oauth-scopes': 'repo', 223 'x-content-type-options': 'nosniff', 224 'x-frame-options': 'deny', 225 'x-github-media-type': 'github.v3; format=json', 226 'x-github-request-id': '0403:137D:13A0B:33855:5F75E751', 227 'x-oauth-scopes': 'gist, notifications, public_repo, read:discussion, read:enterprise, read:org, read:packages, read:public_key, read:repo_hook, read:user, repo:invite, repo:status, user:email, workflow', 228 'x-ratelimit-limit': '5000', 229 'x-ratelimit-remaining': '0', 230 'x-ratelimit-reset': '1601565030', 231 'x-ratelimit-used': '5000', 232 'x-xss-protection': '1; mode=block' 233 }, 234 request: { 235 method: 'GET', 236 url: 'https://api.github.com/repos/spring-media/rbbt-jenkins-slave-image/issues/comments?since=2020-07-03T00%3A00%3A00.000Z&per_page=100', 237 Error: API rate limit exceeded for user ID 1097566. 238 headers: { 239 accept: 'application/vnd.github.v3+json', 240 'user-agent': 'octokit-rest.js/18.0.6 octokit-core.js/3.1.2 Node.js/12.13.1 (linux; x64)', 241 authorization: 'token [REDACTED]' 242 }, 243 request: { hook: [Function: bound bound register], retryCount: 4 } 244 }, 245 documentation_url: 'https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting' 246 }

peter-murray commented 4 years ago

Thanks for raising this.

The API for octokit is being initialized with a throttling and backoff support included, so when/if you get rate limited, it reads the backoff time from the headers and acts accordingly.

It should be backing off and waiting, but this seems to have failed on already exceeded the number of retries (which is currently set to 4).

Could you provide some context as the organization so that I can look to replicate and validate some assumptions that are made in this action.

peter-murray commented 3 years ago

This has been resolved in the v1 and `main branch. There is a sensible default for the Octokit REST API error/backoff handing which can now be further configured by an action parameter.