Skip to content

Commit

Permalink
fix: adapt to GitHub's rename of abuse limit to secondary rate limit (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dontcallmedom authored Sep 6, 2021
1 parent 325e3ee commit 6c361d4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function throttling(octokit: Octokit, octokitOptions = {}) {
options.request.retryCount = retryCount;

const { wantRetry, retryAfter } = await (async function () {
if (/\babuse\b/i.test(error.message)) {
if (/\bsecondary rate\b/i.test(error.message)) {
// The user has hit the abuse rate limit. (REST and GraphQL)
// https://docs.github.com/en/rest/overview/resources-in-the-rest-api#abuse-rate-limits

Expand Down
6 changes: 3 additions & 3 deletions test/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe("Events", function () {
status: 403,
headers: { "retry-after": "60" },
data: {
message: "You have been rate limited to prevent abuse",
message: "You have exceeded a secondary rate limit",
},
},
],
Expand Down Expand Up @@ -112,7 +112,7 @@ describe("Events", function () {
status: 403,
headers: { "retry-after": "2" },
data: {
message: "You have been rate limited to prevent abuse",
message: "You have exceeded a secondary rate limit",
},
},
],
Expand Down Expand Up @@ -156,7 +156,7 @@ describe("Events", function () {
status: 403,
headers: {},
data: {
message: "You have been rate limited to prevent abuse",
message: "You have exceeded a secondary rate limit",
},
},
],
Expand Down
6 changes: 3 additions & 3 deletions test/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("Retry", function () {
{
status: 403,
headers: { "retry-after": "1" },
data: { message: "You have been rate limited to prevent abuse" },
data: { message: "You have exceeded a secondary rate limit" },
},
{ status: 200, headers: {}, data: { message: "Success!" } },
],
Expand Down Expand Up @@ -69,7 +69,7 @@ describe("Retry", function () {
},
});

const message = "You have been rate limited to prevent abuse";
const message = "You have exceeded a secondary rate limit";
try {
await octokit.request("GET /route", {
request: {
Expand Down Expand Up @@ -366,7 +366,7 @@ describe("Retry", function () {
},
data: {
message:
"You have triggered an abuse detection mechanism. Please wait a few minutes before you try again.",
"You have exceeded a secondary rate limit. Please wait a few minutes before you try again.",
documentation_url:
"https://developer.github.com/v3/#abuse-rate-limits",
},
Expand Down

0 comments on commit 6c361d4

Please sign in to comment.