Log when throttling happens

Also centralise the config.
This commit is contained in:
Oliver Hamlet
2026-01-11 17:52:19 +00:00
parent 73a5075daf
commit ffc5665b4e
3 changed files with 27 additions and 13 deletions
+25 -1
View File
@@ -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
});
}
+1 -6
View File
@@ -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'
+1 -6
View File
@@ -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',