-
Notifications
You must be signed in to change notification settings - Fork 555
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(request): optionally retry all network failures #280
Conversation
3976bb1
to
e497dc9
Compare
e497dc9
to
3b58964
Compare
@nbrustein Thanks for the PR. Right now, we're not ready to add official retry support to the bindings. We are, however, thinking about the best way to add this in the future. Stay tuned! |
Could you tell me if there's anything special I would need to look out for if I was gonna start using something like this now? Any reason this approach would not work or be unsafe? |
Would love to see this or a similar mechanism in place soon! |
@nbrustein Nope, nothing inherently wrong with your approach. To prevent tight loops, you should put in exponential backoff when retrying requests. |
@kyleconroy I just wanted to come back and hassle you one more time about pulling this in. We're trying to update our stripe gem today, and we have to deal with the fact that we have this special retry logic that we have to make sure isn't conflicting with any other changes. I don't really understand your explanation for rejecting it. It sounds like you're saying "we think this is a good feature, but we'd rather write it ourselves instead of having someone else do it for us." I don't mean to be annoying. I know that it's work for you guys to look more closely at this and decide whether to pull it in, but it's good functionality that would be useful to all of your users. It's done and it works. We've tested it in production for a couple months. If I put in the exponential backoff would you merge it into master? |
There is still quite a bit of work to be done with this patch before we can merge in into master. A few things off the top of my head:
We'll also need to take a pass over the proposed interface and make sure it's something we're comfortable committing to. |
@kyleconroy Thanks for your suggestions. I've resubmitted this as a new PR: #353 |
If
Stripe. max_retries_on_network_failure
is set to a value greater than 0, then any request that fails on a connection error will be retried (with the exception of RestClient::SSLCertificateNotVerified).If the retry succeeds, then the response will be returned just as if it succeeded on the first try. If the request still fails after
Stripe. max_retries_on_network_failure
attempts, then the last error will be raised.Since it is not safe to retry posts with out an idempotency_key, this code also ensures that there is always an idempotency_key if max_retries_on_network_failure is greater than 0.