ljharb / can-merge

MIT License
15 stars 3 forks source link

rate limited during `--watch` #51

Open ljharb opened 2 years ago

ljharb commented 2 years ago
output ```sh $ can-merge --remote=source --watch && git push source && git push origin Waiting for all checks to complete ... .................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................$CAN_MERGE_REPO/node_modules/@octokit/graphql/dist-node/index.js:81 throw new GraphqlResponseError(requestOptions, headers, response.data); ^ GraphqlResponseError: Request failed due to following response errors: - API rate limit exceeded for user ID 45469. at $CAN_MERGE_REPO/node_modules/@octokit/graphql/dist-node/index.js:81:13 at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) at async runQuery ($CAN_MERGE_REPO/utils/runQuery.js:9:19) at async watch ($CAN_MERGE_REPO/utils/watch.js:6:19) { request: { query: '\n' + ' {\n' + ' search(query: "is:pr repo:yannickcr/eslint-plugin-react sha:541ea43079 undefined", type:ISSUE, first: 100) {\n' + ' issueCount\n' + ' edges {\n' + ' node {\n' + ' ... on PullRequest {\n' + ' \n' + ' state\n' + ' url\n' + ' title\n' + ' number\n' + ' merged\n' + ' mergeable\n' + ' reviewDecision\n' + ' potentialMergeCommit {\n' + ' commitUrl\n' + ' }\n' + ' commits(last: 1) {\n' + ' nodes {\n' + ' commit {\n' + ' statusCheckRollup {\n' + ' state\n' + ' contexts(last: 100) {\n' + ' totalCount\n' + ' pageInfo {\n' + ' endCursor\n' + ' hasNextPage\n' + ' }\n' + ' nodes {\n' + ' __typename\n' + ' ... on CheckRun {\n' + ' status\n' + ' name\n' + ' conclusion\n' + ' }\n' + ' ... on StatusContext {\n' + ' state\n' + ' context\n' + ' description\n' + ' }\n' + ' }\n' + ' }\n' + ' }\n' + ' }\n' + ' }\n' + ' }\n' + '\n' + ' }\n' + ' }\n' + ' }\n' + ' }\n' + ' }\n' + ' ', headers: { authorization: 'token $TOKEN' } }, headers: { 'access-control-allow-origin': '*', 'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset', connection: 'close', 'content-encoding': 'gzip', 'content-security-policy': "default-src 'none'", 'content-type': 'application/json; charset=utf-8', date: 'Thu, 27 Jan 2022 19:52:00 GMT', 'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', server: 'GitHub.com', 'strict-transport-security': 'max-age=31536000; includeSubdomains; preload', 'transfer-encoding': 'chunked', vary: 'Accept-Encoding, Accept, X-Requested-With', 'x-accepted-oauth-scopes': 'repo', 'x-content-type-options': 'nosniff', 'x-frame-options': 'deny', 'x-github-media-type': 'github.v3; format=json', 'x-github-request-id': 'CB73:9DCA:76E5C:91189:61F2F7DF', 'x-oauth-scopes': 'read:discussion, read:enterprise, read:gpg_key, read:org, read:packages, read:public_key, read:repo_hook, read:user, repo, user:email, user:follow', 'x-ratelimit-limit': '5000', 'x-ratelimit-remaining': '0', 'x-ratelimit-reset': '1643314011', 'x-ratelimit-resource': 'graphql', 'x-ratelimit-used': '5000', 'x-xss-protection': '0' }, response: { errors: [ { type: 'RATE_LIMITED', message: 'API rate limit exceeded for user ID 45469.' } ] }, errors: [ { type: 'RATE_LIMITED', message: 'API rate limit exceeded for user ID 45469.' } ], data: undefined } ```

Action items:

MaheraFurniturewala commented 2 years ago

Hi there! Was exploring the codebase and thought I could start working on this issue. If this issue is available, can I go for it?

Green-Ranger11 commented 2 years ago

I'm not working on this but I had a play around locally and here's something to help you get started:

  rateLimit {
    limit
    cost
    remaining
    resetAt
  }

Just add that object as part of the query in buildQuery.js and after every subsequent api call it should return all of the data above. More details found here

MaheraFurniturewala commented 2 years ago

This is super helpful! Thank you @Green-Ranger11

I'm not working on this but I had a play around locally and here's something to help you get started:

  rateLimit {
    limit
    cost
    remaining
    resetAt
  }

Just add that object as part of the query in buildQuery.js and after every subsequent api call it should return all of the data above. More details found here

deepti-96 commented 2 years ago

Hey! While exploring the codebase I felt I could try working on this issue. Since @MaheraFurniturewala has already picked it up, could I collaborate with her?

ljharb commented 2 years ago

Go for it!

Green-Ranger11 commented 2 years ago

@ljharb I believe the first two action items are already done:

  • ensure the token is never outputted to the console; i nearly posted this issue containing it unredacted catch this kind of error and report it better
  • catch this kind of error and report it better

via #50 and our conversation here

I believe all that's left is the rate limit if I'm not mistaken

Edit: ljharb/repo-report shows a nice little message after each run to show the number of api points left.