Skip to content

Commit

Permalink
fix: set onSecondaryRateLimit and onRateLimit options (#16)
Browse files Browse the repository at this point in the history
Apparently these are required options. Should fix issues with the latest
common-config-elixir runs.
  • Loading branch information
btkostner authored Jul 13, 2023
1 parent a2c3415 commit 3d9d6b8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/octokit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import type { Octokit } from "@octokit/core";
import { getOctokit as upstreamOctokit } from "@actions/github";
import { retry } from "@octokit/plugin-retry";
import { throttling } from "@octokit/plugin-throttling";

function onLimit(
retryAfter: number,
{ method, url }: { method: string; url: string },
octokit: Octokit,
) {
octokit.log.warn(`Request quota exhausted for request ${method} ${url}`);
octokit.log.info(`Retrying after ${retryAfter} seconds`);
return true;
}

export function getOctokit(token: string) {
return upstreamOctokit(
token,
Expand All @@ -11,6 +22,8 @@ export function getOctokit(token: string) {
},
throttle: {
enabled: true,
onSecondaryRateLimit: onLimit,
onRateLimit: onLimit,
timeout: 1000 * 60 * 20,
},
},
Expand Down

0 comments on commit 3d9d6b8

Please sign in to comment.