teampoltergeist / poltergeist

A PhantomJS driver for Capybara
MIT License
2.5k stars 415 forks source link

Capybara::Poltergeist::TimeoutError when running CI tests #917

Closed DeeDeeG closed 6 years ago

DeeDeeG commented 6 years ago

Meta

Poltergeist Version: 1.16.0 PhantomJS Version: 2.1.1

Expected Behavior

Poltergeist should not have time outs when running our CI tests.

Actual Behavior

I am a member of the volunteer team over at Refuge Restrooms. We use Capybara and Poltergeist in a lot of our continuous integration tests.

This time out error started happening out of the blue for a few of our sub-tests, and since then every CI run has these time outs (on the same sub-tests, I think). It did not happen after any particular change in our repo, as far as we can tell.

      Timed out waiting for response to {"id":"b334ecf3-e008-40ee-8a48-ae3eee921403","name":"find","args":["css","#list .listItem"]}. 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. (Capybara::Poltergeist::TimeoutError)

We did try increasing the timeout to 60, and a bunch of other things, but none of them eliminated or reduced the errors.

Steps to reproduce

Two options:

(If we can be more helpful by providing the compiled haml --> html of our page, or snippets of our Cucumber/RSpec tests, or generally providing more info, let us know. Thank you.)

twalpole commented 6 years ago

If you run it with selenium as the driver you can see the same things happens, and see the browser is waiting for a request from csi.gstatic.com. The issue appears to be that the map display hangs requesting resources to populate the iframe it adds to the page. You can get the tests to run (some fail) by configuring the driver to ignore JS errors and blacklist googleapis.com -

  Capybara::Poltergeist::Driver.new(app,
    :js_errors => false,
    url_blacklist: ['googleapis.com']
  )

This means you won't actually be able to test anything relating to the map, but I'm not sure what else can be done if the map display just hangs.

DeeDeeG commented 6 years ago

Thanks for the response and explanation. It looks like this is not a Poltergeist or PhantomJS bug after all.

twalpole commented 6 years ago

@DeeDeeG Well there is an issue in that Poltergeist currently doesn't allow setting the PhantomJS resourceTimeout - http://phantomjs.org/api/webpage/property/settings.html - which I think would prevent this from hanging (not actually tested that though).

thebradhimself commented 6 years ago

Our tests see this error about 15% of the time. We need to re-run the tests up to four times to get tests to pass.

"Capybara::Poltergeist::TimeoutError: Timed out waiting for response to {"id":"bb64b980-a6bb-4671-93e7-4931873d9411","name":"visit","args":["http://localhost:3003/dashboard"]}"

twalpole commented 6 years ago

@thebradhimself And have you tried increasing the timeout in your Poltergeist config?? The error is telling you that your page at "http://localhost:3003/dashboard" isn't returning within the allotted time, check your test log to see why it's so slow or increase the allowed time.

simi commented 6 years ago

@thebradhimself Are you using sprockets? Isn't first request compiling assets?

thebradhimself commented 6 years ago

Setting the timeout to be way higher did the tricker @twalpole , thank you!