Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not retry on 501 #197

Merged
merged 3 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/request-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ export class RequestWrapper {
retry: 4, // 4 retries by default
retryDelay: 1000, // 1000 ms (1 sec) initial delay
httpMethodsToRetry: ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT', 'POST'],
// do not retry on 501
statusCodesToRetry: [
[429, 429],
[500, 500],
[502, 599],
],
instance: axiosInstance,
backoffType: 'exponential',
checkRetryAfter: true, // use Retry-After header first
Expand Down
13 changes: 13 additions & 0 deletions test/unit/retry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ describe('Node Core retries', () => {
await service.createRequest(parameters).catch((err) => expect(err).toBeDefined());
});

it('should not retry on 501`', async () => {
const scopes = [
nock(url).get('/').reply(501, undefined),
nock(url).get('/').reply(200, 'retry success!'),
];

let err;
await service.createRequest(parameters).catch((error) => {
err = error;
});
expect(err).toBeDefined();
});

it('should not retry after we call disableRetries', async () => {
const scopes = [
nock(url).get('/').reply(500, undefined),
Expand Down