Conversation
| const MyOctokit = Octokit.plugin(throttling); | ||
| const auth = await credentials.getAccessToken(); | ||
|
|
||
| const octokit = new MyOctokit({ | ||
| auth, | ||
| throttle: { | ||
| onRateLimit: (retryAfter: number, options: any): boolean => { | ||
| void showAndLogWarningMessage( | ||
| `Request quota exhausted for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds!`, | ||
| ); | ||
|
|
||
| return true; | ||
| }, | ||
| onSecondaryRateLimit: (_retryAfter: number, options: any): void => { | ||
| void showAndLogWarningMessage( | ||
| `SecondaryRateLimit detected for request ${options.method} ${options.url}`, | ||
| ); | ||
| }, | ||
| }, | ||
| }); | ||
|
|
There was a problem hiding this comment.
Curiously I never hit the secondary Rate Limit during testing. However, the RateLimit was hit. Even though throttling was used the maximum entries in one list I ever got with one search was 901.
There was a problem hiding this comment.
Even though throttling was used the maximum entries in one list I ever got with one search was 901.
Is this because of throttling, or because of duplicate repos in the search results? If you didn't hit the secondary rate limit then it means you should have results from all 10 pages, but it's just the total number of unique repositories was 901.
There was a problem hiding this comment.
It seems to be this certain search query. I tested with some other queries and had different results.
There was a problem hiding this comment.
I was told the search api returns different results when sending the same request multiple times, this doesn't seem to be true for me right now..
013a691 to
92c86bc
Compare
robertbrignull
left a comment
There was a problem hiding this comment.
Some thoughts on wording of things, but I've tried this out and it worked for me.
I don't know too much about this throttling plugin or how the github rate limit behaves, so I can't comment too much on that part right now. If you'd like a deeper review of that part just let me know.
I also found the progress reporting a bit confusing, but it seemed to work well enough in practice when I ran some searches.
| const auth = await credentials.getAccessToken(); | ||
|
|
||
| const octokit = new MyOctokit({ | ||
| auth, |
There was a problem hiding this comment.
To copy more closely what we do at
, this should ideally include theretry plugin too. Or is that intentionally missed out? The idea of this plugin is that'll automatically retry requests in cases of a 500 error.
| auth, | |
| auth, | |
| retry, |
There was a problem hiding this comment.
I don't think we need the retry plugin here, as the throttle plugin is taking over retrying?
There was a problem hiding this comment.
I believe they deal with different concerns. The retry plugin will retry in response to 5xx errors. The throttle plugin will retry in response to 429 (Too many requests) errors and understands GitHub's specific messages.
But seems that in the latest version of provideOctokitWithThrottling the retry plugin is included, so that all looks good to me.
| }, | ||
| onSecondaryRateLimit: (_retryAfter: number, options: any): void => { | ||
| void showAndLogWarningMessage( | ||
| `SecondaryRateLimit detected for request ${options.method} ${options.url}`, |
There was a problem hiding this comment.
| `SecondaryRateLimit detected for request ${options.method} ${options.url}`, | |
| `Request quota exceeded for request ${options.method} ${options.url}`., |
Just a suggestion to make this error fit with the other one.
There was a problem hiding this comment.
I think it makes sense to distinguish between the two, so that users know what they are hitting specifically.
There was a problem hiding this comment.
I agree users should be able to distinguish and understand them. I was meaning more that we could make the language style more consistent between the two error messages. For example:
- In one we say "quota" and in the other we say "limit". Is there a technical different between these I'm not aware of, and will the user know what they mean?
- In one we use full sentences, and in the other we use CamelCase.
However, this is something that can easily be changed afterwards, if time is tight. So it's ok to defer this to a later PR if needed.
There was a problem hiding this comment.
I took this from the documentation and it copies also a script we have somewhere else in the repo. However you're right with the CamelCase, that's just weird. I fixed the CC and adjusted the wording!
| throttle: { | ||
| onRateLimit: (retryAfter: number, options: any): boolean => { | ||
| void showAndLogWarningMessage( | ||
| `Request quota exhausted for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds!`, |
There was a problem hiding this comment.
The first time it retried after 42 seconds for me, after that 0. I don't know why it retries after 0 seconds, this behaviour comes from the plugin. I also found retries after 10, 20 or 7 seconds in the logs, but we would have to check the code of the plugin to find out more.
| const MyOctokit = Octokit.plugin(throttling); | ||
| const auth = await credentials.getAccessToken(); | ||
|
|
||
| const octokit = new MyOctokit({ | ||
| auth, | ||
| throttle: { | ||
| onRateLimit: (retryAfter: number, options: any): boolean => { | ||
| void showAndLogWarningMessage( | ||
| `Request quota exhausted for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds!`, | ||
| ); | ||
|
|
||
| return true; | ||
| }, | ||
| onSecondaryRateLimit: (_retryAfter: number, options: any): void => { | ||
| void showAndLogWarningMessage( | ||
| `SecondaryRateLimit detected for request ${options.method} ${options.url}`, | ||
| ); | ||
| }, | ||
| }, | ||
| }); | ||
|
|
There was a problem hiding this comment.
Even though throttling was used the maximum entries in one list I ever got with one search was 901.
Is this because of throttling, or because of duplicate repos in the search results? If you didn't hit the secondary rate limit then it means you should have results from all 10 pages, but it's just the total number of unique repositories was 901.
|
@robertbrignull Reviewing this code I noticed that the gh-api-client file where the |
I think this refactoring makes sense - having the API client related code into one file inside Whether that refactoring is done in this PR or a separate one is something that I'll leave to you and @robertbrignull to decide though 😃 |
bbc6595 to
2ecec54
Compare
robertbrignull
left a comment
There was a problem hiding this comment.
LGTM, especially given that this is now behind a feature flag.
I did notice a couple of tiny bits we can improve regarding the cancellation token, but we can discuss those outside of this PR. I'll raise issues or discuss them with you.
robertbrignull
left a comment
There was a problem hiding this comment.
LGTM, especially given that this is now behind a feature flag.
I did notice a couple of tiny bits we can improve regarding the cancellation token, but we can discuss those outside of this PR. I'll raise issues or discuss them with you.
2ecec54 to
945594d
Compare

Instead of using repo search we want to use the code search api for this feature. Since the search api returns an error if two language parameters are added we made the entry of a language through the UI optional.
Items:
Checklist
ready-for-doc-reviewlabel there.