Skip to content

Commit 7ae9006

Browse files
authored
fix: do not retry status code 451 by default (#447)
451 is returned when a resource has been restricted for legal reasons. Retrying this status needlessly wastes API quota
1 parent 5cda721 commit 7ae9006

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# plugin-retry.js
22

3-
> Retries requests for server 4xx/5xx responses except `400`, `401`, `403`, `404`, and `422`.
3+
> Retries requests for server 4xx/5xx responses except `400`, `401`, `403`, `404`, `422`, and `451`.
44
55
[![@latest](https://img.shields.io/npm/v/@octokit/plugin-retry.svg)](https://www.npmjs.com/package/@octokit/plugin-retry)
66
[![Build Status](https://github.com/octokit/plugin-retry.js/workflows/Test/badge.svg)](https://github.com/octokit/plugin-retry.js/actions?workflow=Test)

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function retry(octokit: Octokit, octokitOptions: any) {
1111
{
1212
enabled: true,
1313
retryAfterBaseValue: 1000,
14-
doNotRetry: [400, 401, 403, 404, 422],
14+
doNotRetry: [400, 401, 403, 404, 422, 451],
1515
retries: 3,
1616
},
1717
octokitOptions.retry

test/retry.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ describe("Automatic Retries", function () {
205205
expect(ms2).toBeGreaterThan(420);
206206
});
207207

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

213213
for (const status of testStatuses) {
214214
try {
@@ -241,7 +241,7 @@ describe("Automatic Retries", function () {
241241
},
242242
});
243243
let caught = 0;
244-
const testStatuses = [304, 400, 401, 403, 404];
244+
const testStatuses = [304, 400, 401, 403, 404, 422, 451];
245245

246246
for (const status of testStatuses) {
247247
try {

0 commit comments

Comments
 (0)