mirror of
https://github.com/loot/loot.github.io.git
synced 2026-07-27 14:13:30 -07:00
Log when throttling happens
Also centralise the config.
This commit is contained in:
+25
-1
@@ -1,4 +1,28 @@
|
||||
import { Octokit as RealOctokit } from '@octokit/rest';
|
||||
import { throttling } from '@octokit/plugin-throttling';
|
||||
|
||||
export const Octokit = RealOctokit.plugin(throttling);
|
||||
export function Octokit(options) {
|
||||
const ThrottledOctokit = RealOctokit.plugin(throttling);
|
||||
|
||||
return new ThrottledOctokit({
|
||||
throttle: {
|
||||
onRateLimit: (retryAfter, options) => {
|
||||
console.warn(
|
||||
`Request quota exhausted for request ${options.method} ${options.url}`,
|
||||
);
|
||||
|
||||
console.info(`Retrying after ${retryAfter} seconds!`);
|
||||
return true;
|
||||
},
|
||||
onSecondaryRateLimit: (retryAfter, options) => {
|
||||
console.warn(
|
||||
`SecondaryRateLimit detected for request ${options.method} ${options.url}`,
|
||||
);
|
||||
|
||||
console.info(`Retrying after ${retryAfter} seconds!`);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
...options
|
||||
});
|
||||
}
|
||||
|
||||
@@ -241,12 +241,7 @@ function fixStats(contributorsStats) {
|
||||
}
|
||||
|
||||
async function getContributors() {
|
||||
const octokit = new Octokit({
|
||||
throttle: {
|
||||
onSecondaryRateLimit: () => true,
|
||||
onRateLimit: () => true
|
||||
}
|
||||
});
|
||||
const octokit = new Octokit();
|
||||
|
||||
const repos = await octokit.paginate(octokit.rest.repos.listForOrg, {
|
||||
org: 'loot'
|
||||
|
||||
@@ -78,12 +78,7 @@ function onSearchInit(evt) {
|
||||
console.log("Loading masterlist...");
|
||||
progress.classList.remove('hidden');
|
||||
|
||||
const octokit = new Octokit({
|
||||
throttle: {
|
||||
onSecondaryRateLimit: () => true,
|
||||
onRateLimit: () => true
|
||||
}
|
||||
});
|
||||
const octokit = new Octokit();
|
||||
|
||||
octokit.rest.repos.getContent({
|
||||
owner: 'loot',
|
||||
|
||||
Reference in New Issue
Block a user