Skip to content

Commit

Permalink
Revert to just use shouldRetry function
Browse files Browse the repository at this point in the history
  • Loading branch information
Oligrand committed Jul 20, 2016
1 parent 5572ce9 commit 1c7c309
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function verbFunc(verb) {
});
if (callback) {
params.callback = function (err, resp) {
if (attempts >= maxAttempts || (err && !isRetryableError(err) ) ) {
if (attempts >= maxAttempts || !shouldRetry(err, resp) ) {
if (err || !/2\d\d/.test(resp && resp.statusCode)) {
//unrecoverable error
err = err || new Error('Error in request ' + ((err && err.message) || 'statusCode: ' + (resp && resp.statusCode)));
Expand Down Expand Up @@ -143,12 +143,9 @@ const RETRIABLE_ERRORS = [
'EPIPE',
'EAI_AGAIN'
];
function isRetryableError(err) {
return RETRIABLE_ERRORS.indexOf(err.code) !== -1;
}
function shouldRetry(err, resp) {
if (err) {
return isRetryableError(err);
return RETRIABLE_ERRORS.indexOf(err.code) !== -1;;
}
return resp && /5\d\d/.test(resp.statusCode);
}

0 comments on commit 1c7c309

Please sign in to comment.