ljharb/can-merge

rate limited during `--watch`

Open

#51 opened on Jan 27, 2022

View on GitHub
 (6 comments) (1 reaction) (2 assignees)JavaScript (3 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (15 stars)
PR merge metrics
 (PR metrics pending)

Description

$ 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?

Contributor guide