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

Handle rate limiting #132

Open
bnb opened this issue Aug 3, 2019 · 4 comments
Open

Handle rate limiting #132

bnb opened this issue Aug 3, 2019 · 4 comments

Comments

@bnb
Copy link
Member

bnb commented Aug 3, 2019

Currently, if a user runs too many searches they hit a rate limit. It would be awesome if we could pretty print a message about this rather than logging the JSON :)

~/GitHub/good-first-issue on  master! ⌚ 16:23:45
$ good-first-issue

? Choose a project: EasyGraphQL - EasyGraphQL is a group of open source tools, with the main focus to help developers that use GraphQL or just want to sta
rt using it.
RequestError [HttpError]: API rate limit exceeded for 69.116.190.39. (But here's the good news: Authenticated requests get a higher rate limit. Check out 
the documentation for more details.)
    at /Users/cyren/GitHub/good-first-issue/node_modules/@octokit/request/dist-node/index.js:66:23
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async search (/Users/cyren/GitHub/good-first-issue/lib/search.js:18:20)
    at async Command.<anonymous> (/Users/cyren/GitHub/good-first-issue/bin/good-first-issue.js:30:22) {
  name: 'HttpError',
  status: 403,
  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-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type',
    connection: 'close',
    'content-encoding': 'gzip',
    'content-security-policy': "default-src 'none'",
    'content-type': 'application/json; charset=utf-8',
    date: 'Sat, 03 Aug 2019 20:23:50 GMT',
    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
    server: 'GitHub.com',
    status: '403 Forbidden',
    'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
    'transfer-encoding': 'chunked',
    'x-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-media-type': 'github.v3; format=json',
    'x-github-request-id': 'FE99:32E5:25E774:39DA78:5D45ED56',
    'x-ratelimit-limit': '10',
    'x-ratelimit-remaining': '0',
    'x-ratelimit-reset': '1564863842',
    'x-xss-protection': '1; mode=block'
  },
  request: {
    method: 'GET',
    url: 'https://api.github.com/search/issues?q=org%3Aeasygraphql%20is%3Aissue%20is%3Aopen%20label%3A%22good%20first%20issue%22&sort=updated&order=desc&per_page=30&page=1',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit.js/16.28.5 Node.js/12.7.0 (macOS Mojave; x64)'
    },
    request: { hook: [Function: bound bound register], validate: [Object] }
  },
  documentation_url: 'https://developer.github.com/v3/#rate-limiting'
}
@estrada9166
Copy link
Contributor

Maybe this can be useful https://octokit.github.io/rest.js/#throttling

@jacobrreed
Copy link

@bnb would this be done inside the libgfi project?

@bnb
Copy link
Member Author

bnb commented Sep 20, 2019

Theoretically, yes. Practically, I'm not certain.

Emitting a warning and preventing the process from crashing in libgfi would be ideal, instead returning an error object. Then, catching and pretty printing that there was an error from good-first-issue is the part that we'd want to implement here.

We'd also likely want to support consuming an environment variable that contains a GitHub token so developers can get around default rate limits. May also be worth having a second environment variable to turn that on/off.

@jacobrreed
Copy link

@bnb Please check my pull request I updated libgfi to handle rateLimit and abuseLimit, it now logs one simple line to the user and exits gracefully. I updated the examples and README to reflect this. Let me know if this doesn't satisfy the requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants