From 3d9d6b8dd841d424b829e7536dbce0049d822c53 Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Thu, 13 Jul 2023 16:06:26 -0600 Subject: [PATCH] fix: set onSecondaryRateLimit and onRateLimit options (#16) Apparently these are required options. Should fix issues with the latest common-config-elixir runs. --- src/octokit.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/octokit.ts b/src/octokit.ts index 369f620..81a4d26 100644 --- a/src/octokit.ts +++ b/src/octokit.ts @@ -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, @@ -11,6 +22,8 @@ export function getOctokit(token: string) { }, throttle: { enabled: true, + onSecondaryRateLimit: onLimit, + onRateLimit: onLimit, timeout: 1000 * 60 * 20, }, },