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

Add retries for various failure reasons #164

Merged
merged 3 commits into from
Dec 11, 2019
Merged

Conversation

timhaines
Copy link
Contributor

@timhaines timhaines commented Dec 11, 2019

Have added retries to _httpPost when ECONNRESET is encountered.

Optional Todos:

  • Add to _httpGet as well as _httpPost.
  • We may also want to retry on these: ECONNREFUSED EPIPE EHOSTUNREACH EAI_AGAIN
  • Not certain of the value, but we may also want to check the error is a StatusCodeError for the statuscode retries, and a RequestError for ECONNRESET and friends.

@wwilsman
Copy link
Contributor

RE:

Not certain of the value, but we may also want to check the error is a StatusCodeError for the statuscode retries, and a RequestError for ECONNRESET and friends.

I think it's safe to assume that if there is no statusCode there was no StatusCodeError. We could add it as a sanity check, but it'd probably be a code path that coverage could never reach. Likewise with checking for reason.error.code and RequestError.

@wwilsman wwilsman marked this pull request as ready for review December 11, 2019 17:18
Copy link
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice 🏁

@@ -11,9 +11,20 @@ const fs = require('fs');

require('dotenv').config();

const RETRY_ERROR_CODES = ['ECONNRESET', 'ECONNREFUSED', 'EPIPE', 'EHOSTUNREACH', 'EAI_AGAIN'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Nice

predicate: function(err) {
return err.statusCode >= 500 && err.statusCode < 600;
},
predicate: retryPredicate,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this codebase does the hanging commas too? Hm, we need a consistent lint guide :p

@wwilsman wwilsman merged commit f5f1409 into master Dec 11, 2019
@wwilsman wwilsman deleted the add-retry-on-ECONNRESET branch December 11, 2019 17:27
@Robdel12 Robdel12 changed the title Add retries on ECONNRESET Add retries for various failure reasons Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants