Skip to content
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

Remove uses of Timeout.timeout from Server #2016

Merged
merged 2 commits into from
Apr 18, 2018

Conversation

zetter
Copy link
Contributor

@zetter zetter commented Apr 18, 2018

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 a while loop rather than Timeout.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 uses Timeout.timeout, elsewhere uses a loop similar to the pattern I've followed here.

While we were only seeing problems from the call to Timeout in wait_for_pending_requests, I've changed the other use of Timeout in Server#boot since it was the only other use of Timeout 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.

I expect this to be equivalent since it rases the same error and has the
same pattern of sleeps.
I expect this to be equivalent since it rases the same error and has the
same pattern of sleeps.

I don't know of any problems caused by using timeout here, instead I've
converted this for consistency and so that that there are no longer any
uses of `Timeout.timeout` within the codebase.
@twalpole
Copy link
Member

LGTM - thanks

@twalpole twalpole merged commit 71cd062 into teamcapybara:master Apr 18, 2018
@zetter
Copy link
Contributor Author

zetter commented Apr 18, 2018

@twalpole thanks for merging.

twalpole pushed a commit that referenced this pull request Apr 19, 2018
* Don't use Timeout.timeout in Server#wait_for_pending_requests

I expect this to be equivalent since it rases the same error and has the
same pattern of sleeps.

* Don't use Timeout.timeout in Server#boot

I expect this to be equivalent since it rases the same error and has the
same pattern of sleeps.

I don't know of any problems caused by using timeout here, instead I've
converted this for consistency and so that that there are no longer any
uses of `Timeout.timeout` within the codebase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants