Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: octokit/plugin-throttling.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.1.1
Choose a base ref
...
head repository: octokit/plugin-throttling.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v8.1.2
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Oct 25, 2023

  1. fix(graphql): GraphQL queries can exceed the rate limit even with x-r…

    …atelimit-remaining !== 0. (#636)
    jyasskin authored Oct 25, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    94da99a View commit details
Showing with 9 additions and 4 deletions.
  1. +5 −2 src/index.ts
  2. +4 −2 test/retry.test.ts
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -137,8 +137,11 @@ export function throttling(octokit: Octokit, octokitOptions: OctokitOptions) {
return { wantRetry, retryAfter };
}
if (
error.response.headers != null &&
error.response.headers["x-ratelimit-remaining"] === "0"
(error.response.headers != null &&
error.response.headers["x-ratelimit-remaining"] === "0") ||
(error.response.data?.errors ?? []).some(
(error: any) => error.type === "RATE_LIMITED",
)
) {
// The user has used all their allowed calls for the current time period (REST and GraphQL)
// https://docs.github.com/en/rest/reference/rate-limit (REST)
6 changes: 4 additions & 2 deletions test/retry.test.ts
Original file line number Diff line number Diff line change
@@ -250,7 +250,9 @@ describe("Retry", function () {
{
status: 200,
headers: {
"x-ratelimit-remaining": "0",
// should retry based on response body, not header
// https://github.com/octokit/plugin-throttling.js/issues/632
"x-ratelimit-remaining": "1",
"x-ratelimit-reset": "123",
},
data: { errors: [{ type: "RATE_LIMITED" }] },
@@ -300,7 +302,7 @@ describe("Retry", function () {
{
status: 200,
headers: {
"x-ratelimit-remaining": "0",
"x-ratelimit-remaining": "1",
"x-ratelimit-reset": "123",
},
data: { errors: [{ type: "RATE_LIMITED" }] },