Remove uses of Timeout.timeout
from Server
#2016
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've recently had some intermittent failures in our test suite with the error 'Requests did not finish in 60 seconds'. After investigating we found that the block passed to
Timeout.timeout
that was hanging. We were unable to find out why, but re-writing the code to use awhile
loop rather thanTimeout.timeout
stopped the issue from occurring. You can read more on the mailing list.Even if the intermittent problem is only effecting us, I think this change could be justified as an improvement. Timeout is generally considered dangerous to use since the exception may interrupt the code at any point. The
Server
class is the only part of capybara that usesTimeout.timeout
, elsewhere uses a loop similar to the pattern I've followed here.While we were only seeing problems from the call to
Timeout
inwait_for_pending_requests
, I've changed the other use ofTimeout
inServer#boot
since it was the only other use ofTimeout
in the codebase.Since this timeout pattern exists in lots of places in capybara I looked at extracting it into
Capybara::Helpers
to make it easier to follow, however because of the diversity of the way that the timeouts work (different timings, predicates, sleep intervals and errors raised) I found it hard to bring together if without changing the existing behaviour or passing in lots of arguments & multiple blocks so decided not to.