Timeout on visit root_path

Recently, my team and I have been coming across an odd error in our unit tests in Circle. Once we get to the pages tests, running through rspec, we invariably get Capybara::Poltergeist::TimeoutError on one or at most 2 tests. It highlights visit root_path or visit *_path which is specified in the beforeEach of our suites, but only breaks that once and not again for later tests. This is impeding our process.

We have increased timeouts and are at a loss for what to do next. Stable builds fail when rebuilt and no code change. Any thoughts?

bundle exec rspec -c --no-profile -fp -t ~type:application
Run options: exclude {:type=>“application”}

Randomized with seed 54735
F…

Failures:

  1. Category Specific Page has bar chart
    Failure/Error: visit root_path

    Capybara::Poltergeist::TimeoutError:
    Timed out waiting for response to {“id”:“4b39f3c4-0d28-44c1-af01-3cff25804e3d”,“name”:“visit”,“args”:[“http://127.0.0.1:58269/”]}. It’s possible that this happened because something took a very long time (for example a page load was slow). If so, setting the Poltergeist :timeout option to a higher value will help (see the docs for details). If increasing the timeout does not help, this is probably a bug in Poltergeist - please report it to the issue tracker.

    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:98:in `rescue in send’

    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:94:in `send’

    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/poltergeist-1.8.1/lib/capybara/poltergeist/server.rb:33:in `send’

    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/poltergeist-1.8.1/lib/capybara/poltergeist/browser.rb:340:in `command’

    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/poltergeist-1.8.1/lib/capybara/poltergeist/browser.rb:34:in `visit’

    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/poltergeist-1.8.1/lib/capybara/poltergeist/driver.rb:95:in `visit’

    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/capybara-2.6.0/lib/capybara/session.rb:232:in `visit’

    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/capybara-2.6.0/lib/capybara/dsl.rb:51:in `block (2 levels) in module:DSL

    ./spec/features/category_spec.rb:6:in `block (2 levels) in <top (required)>’

    ------------------

    — Caused by: —

    Errno::EAGAIN:

    Resource temporarily unavailable

    /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/poltergeist-1.8.1/lib/capybara/poltergeist/web_socket_server.rb:78:in `receive’

It seems that rspec fails on the first test, even when randomized, so we shoehorned in an obligatrory test to spin it up before the actual suite. This seems to have cleared up the issue, but having to put in such a patch does not have the team morale high.