Skip to content
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

rate limited during --watch #51

Open
ljharb opened this issue Jan 27, 2022 · 6 comments
Open

rate limited during --watch #51

ljharb opened this issue Jan 27, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request help wanted PRs are welcome!

Comments

@ljharb
Copy link
Owner

ljharb commented Jan 27, 2022

output
$ 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 (<anonymous>)
    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:

  • 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
  • perhaps monitor the amount of API points remaining, and use some kind of backoff algorithm to avoid eating up all the available API calls
  • when a rate limit happens, perhaps don't abort the --watch, but instead try again after a much longer delay?
@ljharb ljharb added enhancement New feature or request help wanted PRs are welcome! labels Jan 27, 2022
@MaheraFurniturewala
Copy link
Contributor

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
Copy link
Collaborator

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
Copy link
Contributor

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
Copy link

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
Copy link
Owner Author

ljharb commented Feb 15, 2022

Go for it!

@Green-Ranger11
Copy link
Collaborator

Green-Ranger11 commented Feb 17, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted PRs are welcome!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants