good-first-issue
good-first-issue copied to clipboard
Handle rate limiting
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'
}
Maybe this can be useful https://octokit.github.io/rest.js/#throttling
@bnb would this be done inside the libgfi project?
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.
@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.