diff --git a/src/util.ts b/src/util.ts index 88f756bf..b83e5b48 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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; } diff --git a/test/util.ts b/test/util.ts index 0d16f944..fb265259 100644 --- a/test/util.ts +++ b/test/util.ts @@ -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'}];