Skip to content

Commit

Permalink
fix: do not retry status code 451 by default (#447)
Browse files Browse the repository at this point in the history
451 is returned when a resource has been restricted for legal reasons.
Retrying this status needlessly wastes API quota
  • Loading branch information
jahands authored Jul 3, 2023
1 parent 5cda721 commit 7ae9006
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# plugin-retry.js

> Retries requests for server 4xx/5xx responses except `400`, `401`, `403`, `404`, and `422`.
> Retries requests for server 4xx/5xx responses except `400`, `401`, `403`, `404`, `422`, and `451`.
[![@latest](https://img.shields.io/npm/v/@octokit/plugin-retry.svg)](https://www.npmjs.com/package/@octokit/plugin-retry)
[![Build Status](https://github.com/octokit/plugin-retry.js/workflows/Test/badge.svg)](https://github.com/octokit/plugin-retry.js/actions?workflow=Test)
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function retry(octokit: Octokit, octokitOptions: any) {
{
enabled: true,
retryAfterBaseValue: 1000,
doNotRetry: [400, 401, 403, 404, 422],
doNotRetry: [400, 401, 403, 404, 422, 451],
retries: 3,
},
octokitOptions.retry
Expand Down
6 changes: 3 additions & 3 deletions test/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ describe("Automatic Retries", function () {
expect(ms2).toBeGreaterThan(420);
});

it("Should not retry 3xx/400/401/403/422 errors", async function () {
it("Should not retry 3xx/400/401/403/422/451 errors", async function () {
const octokit = new TestOctokit({ retry: { retryAfterBaseValue: 50 } });
let caught = 0;
const testStatuses = [304, 400, 401, 403, 404, 422];
const testStatuses = [304, 400, 401, 403, 404, 422, 451];

for (const status of testStatuses) {
try {
Expand Down Expand Up @@ -241,7 +241,7 @@ describe("Automatic Retries", function () {
},
});
let caught = 0;
const testStatuses = [304, 400, 401, 403, 404];
const testStatuses = [304, 400, 401, 403, 404, 422, 451];

for (const status of testStatuses) {
try {
Expand Down

0 comments on commit 7ae9006

Please sign in to comment.