req
req copied to clipboard
`retry`: Don't retry on nxdomain
in fact the only TransportError we should retry on is timeout and econnrefused.
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.
In terms of matching on timeout and econnrefused, I think we should require exceptions returned from the steps to have a :reason field.
Ref: https://github.com/wojtekmach/req/issues/144#issuecomment-1277753450
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 oh I didn't realise we'd got nxdomain under those circumstances, definitely something to think about, thanks!
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.