diff --git a/lib/capybara/server.rb b/lib/capybara/server.rb index f69c47f11..6e31db4a9 100644 --- a/lib/capybara/server.rb +++ b/lib/capybara/server.rb @@ -90,9 +90,13 @@ def responsive? end def wait_for_pending_requests - Timeout.timeout(60) { sleep(0.01) while pending_requests? } - rescue Timeout::Error - raise "Requests did not finish in 60 seconds" + start_time = Capybara::Helpers.monotonic_time + while pending_requests? + if (Capybara::Helpers.monotonic_time - start_time) > 60 + raise "Requests did not finish in 60 seconds" + end + sleep 0.01 + end end def boot @@ -103,11 +107,15 @@ def boot Capybara.server.call(middleware, port, host) end - Timeout.timeout(60) { @server_thread.join(0.1) until responsive? } + start_time = Capybara::Helpers.monotonic_time + until responsive? + if (Capybara::Helpers.monotonic_time - start_time) > 60 + raise "Rack application timed out during boot" + end + @server_thread.join(0.1) + end end - rescue Timeout::Error - raise "Rack application timed out during boot" - else + self end