Conversation
end | ||
|
||
def keep_trying? | ||
return true if @failed.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to initialize @falied as false
and remove this condition?
other than that, your PR looks great! Loved the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If @failed
is false then run
never gets called at all. I'm using it here as a special case to run the first time. I guess I could add a return true if current_attempt == 0
instead, which might be a bit more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use current_attempt.zero?
which makes more sense syntactically.
I'm curious what the motivation for this is. Do you just have a flakey internet connection? |
@@ -0,0 +1,47 @@ | |||
module Bundler | |||
class Retry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include motivation for this class as a class level comment.
Oh I just read the linked PR, I see where this came from. |
@definition.resolve_with_cache! | ||
else | ||
Bundler::Retry.new("source fetch", retry_times).attempts do | ||
@definition.resolve_remotely! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a little surprised to see the retry handled at this level (wrapped around the entire resolution process) rather than at a lower level (like around individual network calls or calls out to git). I'm just wondering why you decided to go that way.
My concern is that this requires resolve_remotely!
to be fully idempotent (or else bugs) and to have enough internal caching that it would avoid redoing work that completed successfully on a previous try. It's not clear to me whether that's the case right now (it looks like it could be, but there's a lot going on in there) and it would be really easy to accidentally break in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was more a proof of concept showing how I could utilize the code, we could push it lower level, or i could rip out this implementation just merge in the Retry class. The key is that there are several areas where we might want to retry code, and writing retry code by hand each time makes those implementations much less clear.
Been a month, i realize priorities are towards speed for this release, but are there any additional thoughts or comments here? Is this PR being considered or should it be closed? |
As a general policy, I think we should retry all failed network requests at least once, and maybe twice, by default. adding --retry to increase the number of retries allowed also seems good. @schneems, are you interested in expanding this to include retrying gem and git fetching, or is gemspecs as far as your interest goes? On Wed, Sep 18, 2013 at 8:02 AM, Richard Schneeman
|
Thanks for the reply. I would be happy to take a stab at retrying in those places. |
Awesome. Thanks! :D |
As of now the feature defaults to 3 attempts (the first plus two retries). To skip retries all together you can run with Added git retry functionality. As implemented it will retry all git commands. This is a pretty invasive change, but the cleanest way to implement the feature. For the gem fetching retry, is this a decent place for the retry functionality https://github.com/bundler/bundler/blob/master/lib/bundler/installer.rb#L107 ? |
can we maybe just whitelist git commands that hit the network? it seems silly to run |
this addresses #2421 |
If someone wants to rebase this, I am 👍 on merging. |
This PR adds a general purpose Retry class that can be re-used where-ever retry code is needed! It also allows you to call `bundle install --retry 3` which will attempt to connect to ruby gems 3 times before failing, and emit a warning message each time
rebased, but we're still retrying on all git commands, haven't had time to work on some kind of whitelisting. I also cleaned up some committed code while rebasing, using custom error classes makes the code much more readable IMHO. |
I'm down, then. Thanks! |
Retry fetch specs with `--retry`
do we want to refactor this to use this new retry class? https://github.com/bundler/bundler/blob/master/lib/bundler/fetcher.rb#L157-L192 |
@flyinprogramer you're welcome to give it a shot, but the Fetcher should only retry on very specific exceptions — the retry class is just a generic retry thing. |
I would add an arg to the That way you could write something like
|
Oh lols, the tests use stabby proc >:| |
Whoops was on auto pilot on that one. I'm at a wedding for the rest of the weekend :/ — On Sat, Sep 28, 2013 at 3:35 PM, André Arko notifications@github.com
|
I fixed it. Have a good weekend! 🤘 On Sat, Sep 28, 2013 at 2:43 PM, Richard Schneeman
|
❤️ 💓 😍 ❤️ |
+1 for this neat feature! when can we expect a PR merge? |
@xbeta the feature had already been shipped with Bundler 1.5, Just update your Bundler to the latest version to use it :) |
@Who828 Cool! I guess I miss that part on the doc! |
This PR adds a general purpose Retry class that can be re-used where-ever retry code is needed!
It also allows you to call
bundle install --retry 3
which will attempt to connect to ruby gems 3 times before failing, and emit a warning message each time.