req icon indicating copy to clipboard operation
req copied to clipboard

`retry`: Don't retry on nxdomain

Open wojtekmach opened this issue 2 years ago • 4 comments

wojtekmach avatar Jul 12 '22 20:07 wojtekmach

in fact the only TransportError we should retry on is timeout and econnrefused.

wojtekmach avatar Jul 12 '22 20:07 wojtekmach

We should also rename default mode :safe to :safe_transient. And add :transient which is :safe_transient except for all methods, including unsafe methods like PUT and POST too.

wojtekmach avatar Jul 25 '22 03:07 wojtekmach

In terms of matching on timeout and econnrefused, I think we should require exceptions returned from the steps to have a :reason field.

wojtekmach avatar Jul 25 '22 05:07 wojtekmach

Ref: https://github.com/wojtekmach/req/issues/144#issuecomment-1277753450

wojtekmach avatar Oct 13 '22 15:10 wojtekmach

this is actually desirable when connecting to a node where it is not known in advance whether it is ipv6 or not, via connect_options: [transport_opts: [inet6: true]]:

iex> Req.get("/_dbs")                                                                                                                             21:27:00.930 [error] retry: got exception, will retry in 1000ms, 3 attempts left

21:27:00.947 [error] ** (Mint.TransportError) non-existing domain
{:ok, %Req.Response{ status: 200, ...

We may get an nxdomain the first time, but succeed on the next pass, when we receive an ipv4 or ipv6 fallback from the previous attempt, via Finch / Mint.

dch avatar Jan 28 '23 21:01 dch

@dch oh I didn't realise we'd got nxdomain under those circumstances, definitely something to think about, thanks!

wojtekmach avatar Feb 10 '23 10:02 wojtekmach

You might also want to retry on econnrefused as another example, since it could be the server being stuffed or other temporary condition. In general I think it's a good idea to retry most transport errors, since most of them can be transient.

whatyouhide avatar Mar 08 '23 23:03 whatyouhide