Skip to content
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
3 changes: 2 additions & 1 deletion src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ export const RETRYABLE_ERR_FN_DEFAULT = function (err?: ApiError) {
reason.includes('eai_again') || // DNS lookup error
reason === 'econnreset' ||
reason === 'unexpected connection closure' ||
reason === 'epipe'
reason === 'epipe' ||
reason === 'socket connection timeout'
);
};

Expand Down
18 changes: 18 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,24 @@ describe('Storage', () => {
assert.strictEqual(calledWith.retryOptions.retryableErrorFn(error), true);
});

it('should retry a socket connection timeout', () => {
const storage = new Storage({
projectId: PROJECT_ID,
});
const calledWith = storage.calledWith_[0];
const error = new ApiError('Broken pipe');
const innerError = {
/**
* @link https://nodejs.org/api/errors.html#err_socket_connection_timeout
* @link https://github.com/nodejs/node/blob/798db3c92a9b9c9f991eed59ce91e9974c052bc9/lib/internal/errors.js#L1570-L1571
*/
reason: 'Socket connection timeout',
};

error.errors = [innerError];
assert.strictEqual(calledWith.retryOptions.retryableErrorFn(error), true);
});

it('should not retry a 999 error', () => {
const storage = new Storage({
projectId: PROJECT_ID,
Expand Down