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

feat: Add retry support for 504 (Gateway Timeout) #704

Merged
merged 1 commit into from
Nov 1, 2021
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
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export class Util {
*/
shouldRetryRequest(err?: ApiError) {
if (err) {
if ([408, 429, 500, 502, 503].indexOf(err.code!) !== -1) {
if ([408, 429, 500, 502, 503, 504].indexOf(err.code!) !== -1) {
return true;
}

Expand Down
6 changes: 6 additions & 0 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,12 @@ describe('common/util', () => {
assert.strictEqual(util.shouldRetryRequest(error), true);
});

it('should return true with error code 504', () => {
const error = new ApiError('504');
error.code = 504;
assert.strictEqual(util.shouldRetryRequest(error), true);
});

it('should detect rateLimitExceeded reason', () => {
const rateLimitError = new ApiError('Rate limit error without code.');
rateLimitError.errors = [{reason: 'rateLimitExceeded'}];
Expand Down