teampoltergeist / poltergeist

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

Capybara::Poltergeist::StatusFailError: check DNS and/or server status #880

Closed kieraneglin closed 7 years ago

kieraneglin commented 7 years ago

Related to #677 and #791. Since both are closed, I'm opening a new discussion.

Problem

When running tests, some will randomly fail. The error is:

Capybara::Poltergeist::StatusFailError: Request to '<app sign_in page, port: 50994>' failed to reach server, check DNS and/or server status

Output with debug: true:

{"id":"76baef53-619e-405a-b940-18d680081839","name":"set_debug","args":[true]}
{"command_id":"76baef53-619e-405a-b940-18d680081839","response":true}
{"id":"206cb602-92fc-404a-a74c-4e70ad516795","name":"set_url_whitelist","args":["<required third party domain>","<local app domain>"]}
{"command_id":"206cb602-92fc-404a-a74c-4e70ad516795","response":true}
{"id":"04221ae6-0769-4b8f-b573-7a75bcf4dbc9","name":"visit","args":["<local sign in page, port: 50994>"]}
{"command_id":"04221ae6-0769-4b8f-b573-7a75bcf4dbc9","error":{"name":"Poltergeist.StatusFailError","args":["<local sign in page>",null]}}

Links redacted for brevity and privacy.

The code it fails on is always visit <path name>

Versions

Things I've Tried

Other Comments

Some people say it only fails on their first test. For me, it's seemingly random as to what tests fail.

There are no iframes on the pages that fail.

kieraneglin commented 7 years ago

Solved!

We were using a custom domain that pointed back to localhost to test subdomains. Adding that domain and subdomains to our hosts file as 127.0.0.1 solved the issue!

twalpole commented 7 years ago

Glad to hear you solved it - I was in the middle of answering this, so I'll leave the explanation in place for others that come to this issue.


The only place StatusFailErrors can come from is https://github.com/teampoltergeist/poltergeist/blob/master/lib/capybara/poltergeist/client/browser.coffee#L111

That shows it can come from either timing out while there are open requests (but the second parameter in your log is null so it's not that), or from the request actually failing. The null parameter would tend to indicate it is because the request is actually failing.

twalpole commented 7 years ago

Oh, and is there a specific reason you're still on Capybara 2.7.1?? That's a pretty old version.

kieraneglin commented 7 years ago

This is literally my first day of work at a new company and I was trying to get everything set up.

So I don't really know why we're using that version of Capybara, but I'll update as soon as I can!

Thanks for the swift reply