Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capybara visit gets stuck for no reason

We have a large cucumber suite for a rails project. It is all capybara and mostly goes via Firefox.

Recently we started to experience a failure, that I am struggling to get my head around. Here is what it looks like:

  • at some point (always the same), capybara visit gets stuck in trying to load the page and capybara eventually times out to find whatever element was looking for (see trace below); every subsequent visit in every other feature also times out;
  • if the feature where it happens run standalone, the problem disappears;
  • if stick debugger (binding.pry) right before the failure, the problem disappears;
  • while it is stuck, if I hit enter in the firefox address bar, request immediately gets through and tests go on and complete without any problems.

One detail that may or may not be relevant: we are using multiple sessions (capybara using_session), so there are three firefox instances by the time of failure. But then again, there are three instances happily passing before that.

The same behaviour shows up on my mate's machine.

Nothing suspicious in rails logs. No sign of that request that is trying to get through.

OSX 10.8.2, ruby 1.9.3, rails 3.2.6, sqlite3, latest capybara/selenium.


Error stack trace:

  Timeout::Error (Timeout::Error)
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/http.rb:1293:in `request'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/http.rb:745:in `start'
  /Users/artem/.rbenv/versions/1.9.3-p194-perf/lib/ruby/1.9.1/net/http.rb:1284:in `request'
  (eval):2:in `has_css?'
  ./features/step_definitions/home_page_steps.rb:70:in `/^I am taken to the products page on the retailer site$/'
  features/home_page.feature:21:in `Then I am taken to the products page on the retailer site'
  Timeout::Error (Timeout::Error)


EDIT

bundle update seems to have made it go away


EDIT 2

If you stuck with a similar problem and you are using FireBug (capybara/firebug), try disabling it.


EDIT 3

It's occurred to me that since've we switched from webrick to thin (in test/development), this never happened. It is as simple as adding gem 'thin' in Gemfile. Might be worth a try.

like image 951
artemave Avatar asked Nov 02 '12 10:11

artemave


1 Answers

bundle update seems to have made it go away

like image 87
artemave Avatar answered Nov 12 '22 12:11

artemave