Faraday: Net::HTTP adapter retries requests automatically

Created on 21 Feb 2018  ·  3Comments  ·  Source: lostisland/faraday

Basic Info

  • Faraday Version: any
  • Ruby Version: 2.5+

Issue description

When using Net::HTTP as adapter, users get surprised by the retry strategy provided by Net::HTTP. This brings to different "issues" (e.g. #612 and #771).
There's not much we can do for Ruby <= 2.4, however Ruby 2.5 provides a new max_retries config for Net::HTTP so Faraday should set that automatically when available.

Steps to reproduce

See issues #612 and #771.

feature help wanted

All 3 comments

I've been looking at this issue. One approach mentioned in #771 is to set the default to 0, but change it depending on the amount of retries configured. We would have to make the Retry middleware aware of the underlying adapter (as some adapters might not support this), and conditionally apply this logic in the env. The adapter would also have to know about the amount of retries.

As an alternative to said approach, we can set it to do no retries, instead keeping the retry logic confined to the Retry middleware. Whatever the outcome, I'd be more than happy to pick this up @iMacTia .

I was definitely thinking at the second option.
We already have the Retry middleware that can take care of retrying failed requests.
Adapters (in this case Net::HTTP) should never retry requests on their own.

All we need to do in this case is to tell Net::HTTP adapter to set max_retries to 0, if this property is available, of course

@iMacTia - I couldn't agree more. In that case, I shall pick this up.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mvastola picture mvastola  ·  4Comments

JasonBarnabe picture JasonBarnabe  ·  4Comments

aleksb86 picture aleksb86  ·  3Comments

luizkowalski picture luizkowalski  ·  3Comments

subvertallchris picture subvertallchris  ·  5Comments