Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress doesn't work when there is no internet connection, testing to localhost #4763

Closed
jodelasur opened this issue Jul 19, 2019 · 7 comments · Fixed by #4774
Closed

Cypress doesn't work when there is no internet connection, testing to localhost #4763

jodelasur opened this issue Jul 19, 2019 · 7 comments · Fixed by #4774

Comments

@jodelasur
Copy link

Current behavior:

Cypress will not load tests to localhost server when there is no internet connection. This happens in both GUI (cypress open) and command line (cypress run).

I'm experiencing something similar to #4235, but the differences are:

  • It only doesn't work when there is no internet connection.
  • When there's no connection, issue happens with both Chrome and Electron

In the console, I see this:

image

I'm not in a corporate proxy server.

Desired behavior:

The tests should still run, since I'm only testing a local server.

Steps to reproduce:

  1. Clone this repo, then npm install. This repo is just create-react-app with a cypress test that visits the home page.
  2. Disconnect internet connection.
  3. npm start to start server. http://localhost:3000 should display the default page for create-react-app.
  4. npm run cypress:open to start Cypress. Then run home.spec.js. You'll see that the test doesn't load.

I also included my logs in the repo. See log.txt.

Versions

Cypress 3.4.0, Windows 10, Chrome 75 and Electron 61

@flotwig flotwig self-assigned this Jul 19, 2019
@brian-mann
Copy link
Member

Cypress should most definitely work offline, @flotwig can you take a look at this?

@bahmutov
Copy link
Contributor

Justin James @digitaldrummerj has asked about it before https://twitter.com/digitaldrummerj/status/1130898592481316864

@flotwig
Copy link
Contributor

flotwig commented Jul 22, 2019

Couldn't reproduce in Ubuntu 19.04, but in Windows 10 can confirm the issue occurs in Chrome & Electron. Working on the "why" now.

@flotwig
Copy link
Contributor

flotwig commented Jul 22, 2019

The root issue appears to be nodejs/node#11320... Node on Windows cannot resolve localhost when there is no active network interface besides 'loopback'.

A fix landed in Node 8.10: nodejs/node#17662, we're on 8.9.3.

An interim fix is to intercept calls to dns.lookup and use os.networkInterfaces() to detect if this problem is going to occur, and if so, strip the problematic flag from dns.lookup. Submitted a PR to fix this (#4774) while we work on upgrading the bundled Node (#3568)

@bahmutov
Copy link
Contributor

bahmutov commented Jul 22, 2019 via email

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 22, 2019

The code for this is done in cypress-io/cypress#4774, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jul 22, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 29, 2019

Released in 3.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants