-
Notifications
You must be signed in to change notification settings - Fork 981
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
Don't call retry_block unless a retry is going to happen #1350
Conversation
ff03083
to
ec9d77e
Compare
Hi @jrochkind and thanks for spotting this! Please add these things to the PR and I think it should be ready to be merged:
|
@iMacTia Thanks for the quick response! Yes, I'll fix the linting (thought I already did but have been fighting with rebasing) and add to UPGRADING. On backwards compat...
Appreciate any thoughts! |
7820d2b
to
ed73067
Compare
…retry_after With basic retry_block specs that didn't exist before.
ed73067
to
92e7e8b
Compare
Points 1-2 make sense! I was thinking about that as well but was hoping that one more parameter would be easier to migrate to. We need to ensure Ruby 2.6 supports them though, as that will be the minimum Ruby version that we'll support with Faraday v2.0. As for point 3, I agree I wouldn't like this PR to blow up though, there are a few good ideas here but we don't necessarily need to have them all implemented together. I'd suggest adding to this PR only the strictly necessary changes (i.e. backwards-incompatible changes), moving the rest to a separate PR. Does that make sense? |
@iMacTia I agree I would do the others as a separate PR, I think this PR is good as is! I don't understand "retired". I would personally replace the current If we switch to keyword args, the names get even more important, compared to positional args. I am positive keyword args in procs/lambdas are fine in ruby 2.6 -- not sure what version they were introduced, but certain it was before 2.6, so if you aren't worried about before 2.6 it's not a problem. I would love to submit that as a separate PR once this one is merged! |
(I believe keyword args in procs/lambdas may have been introduced in ruby 2.2.0. https://docs.ruby-lang.org/en/2.2.0/Proc.html Sounds like that's fine for faraday 2.0!) |
I'm sorry @jrochkind I meant Good plan, I'll review this PR as soon as I have time and we can address the rest in another one 👍 |
@jrochkind just a quick nudge that I'm considering moving the retry middleware into a separate middleware gem as of 2.0. |
Hello, I've been on vacation for the new year holidays since our last exchange, but can submit something on the re-factoring of args on Monday, when I'll be back, whether that's here or another repo! I'm not sure what the name and semantics of the I think it's good to change these arguments' semantics -- and try to get it right -- at the same time as a switch to keyword args, because that keyword arg switch will be an obvious "fail quick" backwards incompat, instead of something that has a greater risk of not raising but not doing what you want, or raising in a more confusing way. Thank you for your engagement on this, and for your maintainance of faraday! |
Hey @jrochkind, no worries at all! We're all busy spending some time with our families and loved ones! I can confirm I've now moved the |
OK I will PR there shortly. Since you've already released it as 1.0, the changes we're talking about will require a 2.0 release. Not sure if that is what you were intending. You are ok with a quick 2.0 release very soon on the heels of that 1.0 @iMacTia ? |
@iMacTia Your CHANGELOG for new 1.0 faraday-retry says:
But it actually also includes the bugfix right here in THIS PR that was never included in a Faraday release, no? Should that be noted? I did include a note on this here in the faraday Phew, a lot of confusing bookkeeping. I'm currently trying to take the code I had already written to be PR'd here, and move it to the new files in the new repo. |
@jrochkind yes a 2.0 release shortly after 1.0 is perfectly fine! 1.0 is really just supposed to be a "moved-out" version. Good shout on the change, I didn't remember that was also technically backwards-incompatible. Although we might argue that was actually solving a bug rather than changing the behaviour, so I doubt that's gonna cause any issue. Still, I agree it should be noted on |
Oh I do NOT actually consider the change here in #1350 to be backwards incompat! Although it's debatable, that's not my opinion. But we list changes that aren't just backwards incompats, bugfixes and such too, right? |
Yeah that makes sense 👍, and it makes me feel better knowing that we both think the change is not dangerous 😄! |
Description
Prior to this PR,
retry_block
could be called in some cases where a retry would not happen. I consider it a bug, and thus not a backwards incompat to change, but feedback welcome?Prior to PR,
retry_block
would not be called if for instance a customretry_if
said not to retry. But it still would be called if if aretry-after
header would exceedmax_interval
, even though no retry would be taking place.After this PR, a present
retry_block
is only called if and only if a retry is actually going to happen. It will not be called if a retry is not going to happen becausemax_interval
has been exceeded by aretry-after
header.Additional Notes
With basic retry_block specs that didn't exist before.
What I really wanted is the actual
sleep_amount
to be available to theretry_block
, so i could log"retrying again in #{sleep_amount}"
. Looking for a way to do that is what made me spot this bug. But I am not sure if there's any way to add that in a backwards-compatible way -- adding another arg to the block is probably not backwards compatible? Is there any other way to slip it in there?Appreciate any advice on if there's a feasible way to make
sleep_amount
available to theretry_block
, for a possible subsequent PR.