Closed pdgonzalez872 closed 1 year ago
Good catch. Looking back not sure what should be the semantics of :always so I will most likely remove it in favor of either more explicit options or leaving this to the user altogether which they can do today via a lambda.
out of curiosity how did you expect this would work?
out of curiosity how did you expect this would work?
We thought it was a "retry until it worked" option. Then we saw retries for 200s and started to look into it more.
I also think we should mention the use-case, it may give more context to you:
We need to retry POST requests. We want exactly what :safe
provides, but for POSTs.
When we saw we were not retrying (because of it being a POST) we looked into retry: :always
. We actually agreed with the approach of NOT allowing that to happen since POSTs in essence alter data. But, some apis ask for POSTs that are really GETs. GraphQL deals with POSTs as well so maybe that's something to consider like you mentioned above.
Thanks for looking into this!
We thought it was a "retry until it worked" option.
Gotcha, that's very reasonable.
We need to retry POST requests. We want exactly what :safe provides, but for POSTs.
Yeah, that's very reasonable too.
I'm thinking about introducing another value, :transient, which means http response 408/5xx or transport error :timeout, :closed and perhaps some others. And then we'd have :safe_transient which is :transient but just for safe HTTP methods.
So for you, retry until it works, it would be: retry: :transient, max_retries: a_large_integer
. I'll add max_retries: :infinity
too. :)
excellent, that'd be great! We like the default max_retries
, but maybe you are seeing something we will likely have to deal with later on and we don't know about it yet 😂
retry: :transient, max_retries: :infinity
-> "don't you stop trying till this is done!"
ah, sorry, just to be clear I think a max_retries < :infinity is the way to go.
yes, for sure. We won't use infinity, I just thought it was funny 😂
Would love a built in :transient
option that works with e.g. POST
Hi @wojtekmach!
Thanks for the library! I've said it many times and every time I get a chance I like to say that I love your work. I love Req too!
I wanted to reach out about the following behavior and see if I am missing something:
I created a small repro script, using
mix_install_examples
(again, amazing work and resource for the community :heart:) as follows:Then, we:
elixir server.exs
elixir req.exs
I guess I misunderstood what
[retry: :always]
meant. I thought it would retry only if needed. If we got a 200, we would not error and try again. Am I missing something?