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

Timed out waiting for the browser to connect #16

Closed
pablorivera opened this issue Nov 1, 2017 · 34 comments
Closed

Timed out waiting for the browser to connect #16

pablorivera opened this issue Nov 1, 2017 · 34 comments
Labels

Comments

@pablorivera
Copy link

Hi,

I'm trying to run cypress run --browser chrome in cypress/browsers:chrome62 image but seems that chrome is not starting. Do you know what the problem could be?

Dockerfile.:

FROM cypress/browsers:chrome62

COPY containers/ci/files /
COPY apps/ci/package.json /apps/ci/package.json

USER root
RUN chown -R person /apps/ci
USER person

RUN set -x \

    # Install node modules
    && cd /apps/ci \
    && npm install

RUN set -x \
    # Create directory structure for saving results
    && mkdir -p /apps/ci/results

COPY apps/ci/ /apps/ci

USER root
RUN chown -R person /apps/ci
USER person

Stacktrace:

person@1adbaed2497a:/apps/ci$ npm run cypress:run
npm info it worked if it ends with ok
npm info using npm@3.10.10
npm info using node@v6.11.1
npm info lifecycle @~precypress:run: @
npm info lifecycle @~cypress:run: @

> @ cypress:run /apps/ci
> cypress run --browser chrome

Warning: Cypress can only record videos when using the built in 'electron' browser.

You have set the browser to: 'chrome'

A video will not be recorded when using this browser.
  (Tests Starting)

Timed out waiting for the browser to connect. Retrying...

Timed out waiting for the browser to connect. Retrying again...

The browser never connected. Something is wrong. The tests cannot run. Aborting...

  (Tests Finished)

  - Tests:           0
  - Passes:          0
  - Failures:        1
  - Pending:         0
  - Duration:        0 seconds
  - Screenshots:     0
  - Video Recorded:  false
  - Cypress Version: 1.0.3


  (All Done)


npm info lifecycle @~cypress:run: Failed to exec cypress:run script
npm ERR! Linux 4.9.49-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "cypress:run"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ cypress:run: `cypress run --browser chrome`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ cypress:run script 'cypress run --browser chrome'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cypress run --browser chrome
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /apps/ci/npm-debug.log
@bahmutov
Copy link
Contributor

bahmutov commented Nov 1, 2017

Not sure why, can you see

  • if chrome prints its version chrome --version in your container
  • see debug info from cypress run using DEBUG=cypress:* environment variable
  • does built-in browser run?

@bahmutov bahmutov added the bug label Nov 1, 2017
@pablorivera
Copy link
Author

Thanks @bahmutov for your quick reply. Below is what I got:

person@17871949b208:/$ google-chrome
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
Trace/breakpoint trap
person@17871949b208:/$ chrome --version
Google Chrome 62.0.3202.62
person@17871949b208:/$ cd apps/ci/
person@17871949b208:/apps/ci$ npm run cypress:debug
npm info it worked if it ends with ok
npm info using npm@3.10.10
npm info using node@v6.11.1
npm info lifecycle @~precypress:debug: @
npm info lifecycle @~cypress:debug: @

> @ cypress:debug /apps/ci
> DEBUG=cypress:* cypress run --browser chrome

  cypress:cli cli starts with arguments ["/usr/local/bin/node","/apps/ci/node_modules/.bin/cypress","run","--browser","chrome"] +0ms
  cypress:cli program parsing arguments +4ms
  cypress:cli running Cypress +6ms
  cypress:cli parsed cli options { browser: 'chrome' } +224ms
  cypress:cli verifying Cypress app +4ms
  cypress:cli path to info.json file /apps/ci/node_modules/cypress/dist/info.json +1ms
  cypress:cli { version: '1.0.3', verifiedVersion: '1.0.3' } +8ms
  cypress:cli installed version is 1.0.3 comparing to 1.0.3 +2ms
  cypress:cli checking if executable exists /apps/ci/node_modules/cypress/dist/Cypress/Cypress +0ms
  cypress:cli path to info.json file /apps/ci/node_modules/cypress/dist/info.json +2ms
  cypress:cli has verified version 1.0.3 +1ms
  cypress:cli run verification check? false +1ms
  cypress:cli processing run options +0ms
  cypress:cli --key is not set, looking up environment variable CYPRESS_RECORD_KEY +0ms
  cypress:cli run to spawn.start args ["--run-project","/apps/ci","--browser","chrome"] +1ms
  cypress:cli needs XVFB? true +1ms
  cypress:cli Starting XVFB +0ms
  cypress:cli spawning Cypress /apps/ci/node_modules/cypress/dist/Cypress/Cypress +49ms
  cypress:cli spawn args ["--run-project","/apps/ci","--browser","chrome"] +0ms
Warning: Cypress can only record videos when using the built in 'electron' browser.

You have set the browser to: 'chrome'

A video will not be recorded when using this browser.
  (Tests Starting)

Timed out waiting for the browser to connect. Retrying...

Timed out waiting for the browser to connect. Retrying again...

The browser never connected. Something is wrong. The tests cannot run. Aborting...

  (Tests Finished)

  - Tests:           0
  - Passes:          0
  - Failures:        1
  - Pending:         0
  - Duration:        0 seconds
  - Screenshots:     0
  - Video Recorded:  false
  - Cypress Version: 1.0.3


  (All Done)

  cypress:cli Stopping XVFB +2m

npm info lifecycle @~cypress:debug: Failed to exec cypress:debug script
npm ERR! Linux 4.9.49-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "cypress:debug"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ cypress:debug: `DEBUG=cypress:* cypress run --browser chrome`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ cypress:debug script 'DEBUG=cypress:* cypress run --browser chrome'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     DEBUG=cypress:* cypress run --browser chrome
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /apps/ci/npm-debug.log

@bahmutov
Copy link
Contributor

bahmutov commented Nov 1, 2017

Weird, maybe the container is too memory limited for Chrome to run?

We are testing Cypress + Chrome browser in https://github.com/cypress-io/cypress-test-node-versions
For example here is a test run: https://circleci.com/gh/cypress-io/cypress-test-node-versions/1242

@pablorivera
Copy link
Author

I don't think that is the problem. It was 2GB so I tried setting it to 4GB but having the same issue. See below:

person@f9c18fbef023:/apps/ci$ free
             total       used       free     shared    buffers     cached
Mem:       4042392     369984    3672408     168268      45576     203404
-/+ buffers/cache:     121004    3921388
Swap:      1048572          0    1048572
person@f9c18fbef023:/apps/ci$ npm run cypress:debug
npm info it worked if it ends with ok
npm info using npm@3.10.10
npm info using node@v6.11.1
npm info lifecycle @~precypress:debug: @
npm info lifecycle @~cypress:debug: @

> @ cypress:debug /apps/ci
> DEBUG=cypress:* cypress run --browser chrome

  cypress:cli cli starts with arguments ["/usr/local/bin/node","/apps/ci/node_modules/.bin/cypress","run","--browser","chrome"] +0ms
  cypress:cli program parsing arguments +3ms
  cypress:cli running Cypress +3ms
  cypress:cli parsed cli options { browser: 'chrome' } +329ms
  cypress:cli verifying Cypress app +2ms
  cypress:cli path to info.json file /apps/ci/node_modules/cypress/dist/info.json +1ms
  cypress:cli { version: '1.0.3', verifiedVersion: '1.0.3' } +5ms
  cypress:cli installed version is 1.0.3 comparing to 1.0.3 +1ms
  cypress:cli checking if executable exists /apps/ci/node_modules/cypress/dist/Cypress/Cypress +0ms
  cypress:cli path to info.json file /apps/ci/node_modules/cypress/dist/info.json +2ms
  cypress:cli has verified version 1.0.3 +1ms
  cypress:cli run verification check? false +0ms
  cypress:cli processing run options +1ms
  cypress:cli --key is not set, looking up environment variable CYPRESS_RECORD_KEY +0ms
  cypress:cli run to spawn.start args ["--run-project","/apps/ci","--browser","chrome"] +0ms
  cypress:cli needs XVFB? true +1ms
  cypress:cli Starting XVFB +0ms
  cypress:cli spawning Cypress /apps/ci/node_modules/cypress/dist/Cypress/Cypress +65ms
  cypress:cli spawn args ["--run-project","/apps/ci","--browser","chrome"] +0ms
Warning: Cypress can only record videos when using the built in 'electron' browser.

You have set the browser to: 'chrome'

A video will not be recorded when using this browser.
  (Tests Starting)

Timed out waiting for the browser to connect. Retrying...

Timed out waiting for the browser to connect. Retrying again...

The browser never connected. Something is wrong. The tests cannot run. Aborting...

  (Tests Finished)

  - Tests:           0
  - Passes:          0
  - Failures:        1
  - Pending:         0
  - Duration:        0 seconds
  - Screenshots:     0
  - Video Recorded:  false
  - Cypress Version: 1.0.3


  (All Done)

  cypress:cli Stopping XVFB +2m

npm info lifecycle @~cypress:debug: Failed to exec cypress:debug script
npm ERR! Linux 4.9.49-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "cypress:debug"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! @ cypress:debug: `DEBUG=cypress:* cypress run --browser chrome`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ cypress:debug script 'DEBUG=cypress:* cypress run --browser chrome'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     DEBUG=cypress:* cypress run --browser chrome
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /apps/ci/npm-debug.log

@brian-mann
Copy link
Member

By any chance are you running this locally say in OSX where its using network filesystem instead of docker having its own dedicated one?

@pablorivera
Copy link
Author

I'm accessing to the container with docker-compose -f docker-compose.yml run ci bash
My docker-compose.yml content is

version: "2"
services:
  ci:
    build:
      context: ./
      dockerfile: containers/ci/Dockerfile
    stdin_open: true
    tty: true

@bahmutov
Copy link
Contributor

bahmutov commented Nov 1, 2017

from Mac OSX right?

@pablorivera
Copy link
Author

Yes, on Mac OSX but also in Bamboo CI

@bahmutov
Copy link
Contributor

bahmutov commented Nov 1, 2017

Ok, can I ask why don't you run Mac Cypress directly? Like why do you need to put it into local Docker container? You don't see the GUI...

@bahmutov
Copy link
Contributor

bahmutov commented Nov 1, 2017

and does Cypress run with built-in electron browser?

@pablorivera
Copy link
Author

On Mac OSX works both, electron and chrome. I'm running it in the Docker container because I need it for CI. As it was not working I was testing it. In the Docker container electron works, but I need to run it with Chrome which doesn't work.

@dineshk-qa
Copy link

Having same issue on Windows 10.
Local run is fine with both electron and chrome but running inside a local container:

  1. Electron - runs fine
  2. Chrome - throws Timed out waiting for the browser to connect. Retrying....
    Although I could run image with chrome --version and it spits Google Chrome 62.0.3202.62

@canakguen
Copy link

canakguen commented Nov 15, 2017

I have the exactly the same problem of cypress timing out. Running it on gitlab ci with the given chrome image. Are there any news about this topic?

I verified the following steps:

  • chrome --version prints Google Chrome 62.0.3202.62 as well
  • Memory is not limited, currently this test is executed on a 64GB root server with no competing tests being run at the same time
  • electron works just fine, chrome does not
  • This is how the CI file looks:
cypress-e2e-chrome:
  image: cypress/browsers:chrome62
  stage: test
  script:    
    - chrome --version
    - npm install --save-dev cypress
    - $(npm bin)/cypress run  --record --key a-beautiful-key --browser chrome
  artifacts:
    expire_in: 1 week
    paths:
    - cypress/screenshots
    - cypress/videos

@bahmutov
Copy link
Contributor

No updates, let me update our GitLab CI example to see if it works

https://gitlab.com/cypress-io/cypress-example-docker-gitlab/issues/3

@bahmutov
Copy link
Contributor

I invite everyone to take a look at Cypress running on GitLab CI (both electron and chrome browser). Maybe the simple test is too small and simple?

@arsduo
Copy link

arsduo commented Nov 30, 2017

FWIW, I'm seeing the same thing on Circle CI 2.0 with the cypress/browsers:chrome62 image. If I open up a terminal in the docker container booted during the CI steps, I can use headless Chrome (for instance, chrome --headless --print-to-pdf http://google.com generates a PDF), but running $(yarn bin)/cypress run --browser chrome in the session fails because it can't connect to the browser.

I've attached the Dockerfile, in case that's useful.

Dockerfile.txt

@arsduo
Copy link

arsduo commented Nov 30, 2017

I tried enabling Cypress debug logging to get more information (DEBUG=cypress:* $(yarn bin)/cypress run --browser chrome), but for some reason the log statements that seem like they should be printed during the Chrome launch process don't actually happen (see below).

Since the log statement's been there since 0.19 (according to Git history) I wonder if that means it's not actually getting launched. None of the promises a few lines up even seem to be running, since I'm not seeing any of the log data that should happen beforehand (for instance, util.path) occur either. Or maybe not, it's always tricky to jump into a new codebase and figure out what's supposed to occur.

root@b297e8fbd510:/usr/src/app# DEBUG=* $(yarn bin)/cypress run --browser chrome
  cypress:cli cli starts with arguments ["/usr/local/bin/node","/usr/src/app/node_modules/.bin/cypress","run","--browser","chrome"] +0ms
  cypress:cli program parsing arguments +3ms
  cypress:cli running Cypress +2ms
  cypress:cli parsed cli options { browser: 'chrome' } +156ms
  cypress:cli verifying Cypress app +2ms
  cypress:cli path to info.json file /usr/src/app/node_modules/cypress/dist/info.json +1ms
  cypress:cli { version: '1.1.2', verifiedVersion: '1.1.2' } +4ms
  cypress:cli installed version is 1.1.2 comparing to 1.1.2 +1ms
  cypress:cli checking if executable exists /usr/src/app/node_modules/cypress/dist/Cypress/Cypress +0ms
  cypress:cli path to info.json file /usr/src/app/node_modules/cypress/dist/info.json +1ms
  cypress:cli has verified version 1.1.2 +1ms
  cypress:cli run verification check? false +0ms
  cypress:cli processing run options +0ms
  cypress:cli --key is not set, looking up environment variable CYPRESS_RECORD_KEY +1ms
  cypress:cli run to spawn.start args ["--run-project","/usr/src/app","--browser","chrome"] +0ms
  cypress:cli needs XVFB? true +0ms
  cypress:cli Starting XVFB +0ms
  cypress:cli spawning Cypress /usr/src/app/node_modules/cypress/dist/Cypress/Cypress +16ms
  cypress:cli spawn args ["--run-project","/usr/src/app","--browser","chrome"] +0ms
Warning: Cypress can only record videos when using the built in 'electron' browser.

You have set the browser to: 'chrome'

A video will not be recorded when using this browser.
  (Tests Starting)

Timed out waiting for the browser to connect. Retrying...

Timed out waiting for the browser to connect. Retrying again...

The browser never connected. Something is wrong. The tests cannot run. Aborting...

  (Tests Finished)

  - Tests:           0
  - Passes:          0
  - Failures:        1
  - Pending:         0
  - Duration:        0 seconds
  - Screenshots:     0
  - Video Recorded:  false
  - Cypress Version: 1.1.2


  (All Done)

  cypress:cli Stopping XVFB +2m

@brian-mann
Copy link
Member

@arsduo appreciate your detailed debugging analysis.

There are actually two problems in play here:

  1. that we are not printing all the debugging logs to stdout. Already an open issue here: Don't ignore stderr from the CLI. Only ignore stderr from the XVFB process cypress#921
  2. that the browser is not being connected to. We can actually repro locally (with a docker container) but haven't spent the time to investigate why. in Circle, buildkite, appveyor it always works. Locally without docker it always works. Something about the docker when running locally (likely in a less performant file system mode) is when it appears

@arsduo
Copy link

arsduo commented Nov 30, 2017

Thanks for the response! That's good to know. FWIW this is actually happening in Docker on Circle CI 2.0 -- we're building the client in a container so that it can interact with a container hosting the server. If there's any additional info I can give you, just let me know.

@cameronc56
Copy link

Thanks for the response, I just ran into this issue.

@cameronc56
Copy link

I'm able to repro this both locally and on Jenkins CI.

@bahmutov
Copy link
Contributor

bahmutov commented Dec 2, 2017 via email

@Graham42
Copy link

Graham42 commented Dec 2, 2017

If you're on a linux machine you should be able to mount the x11 socket to display the window on the host.
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY ...

@brian-mann
Copy link
Member

We are all on OSX

@cameronc56
Copy link

cameronc56 commented Dec 5, 2017

Using the above docker run -v options, with -it, and --shm-size=2g, here is some more info on what I am experiencing:

./chrome.sh found here works fine, chrome opens and is fully functional, though i do get the "make google chrome the default browser" window before the real browser opens. I disabled it by adding --no-default-browser-check to chrome.sh but that doesn't fix the timing out issue

cypress run: Timed out waiting for the browser to connect. Retrying...

cypress open: the client opens
attempting to run a test with chrome 62 here fails - no error log to the console, the "chrome 62" text just switches to "opening" and then immediately back to chrome 62.

@cameronc56
Copy link

If anyone has any other ideas on how I can debug this I'd love to hear it. I'm not sure where to go from here

@brian-mann
Copy link
Member

@bahmutov has been working on this, we'll probably have an update tomorrow or later in the week.

@arsduo
Copy link

arsduo commented Dec 6, 2017 via email

@brian-mann
Copy link
Member

@bahmutov spent a couple hours tracking this down and should have fixes out for 1.1.4 - it was a combination of issues that should all get resolved.

@arsduo
Copy link

arsduo commented Dec 6, 2017 via email

@cameronc56
Copy link

@bahmutov Thanks so much!!!!

@brian-mann
Copy link
Member

Released in 1.1.4.

@bahmutov
Copy link
Contributor

bahmutov commented Dec 7, 2017

I just tested cypress@1.1.4 with latest built Docker image cypress/browsers:chrome63 using project cypress-test-tiny to confirm

Here is the raw output from the terminal (Docker on Mac)

$ docker run -v $PWD:/src -w /src -it cypress/browsers:chrome63 /bin/bash
Unable to find image 'cypress/browsers:chrome63' locally
chrome63: Pulling from cypress/browsers
ad74af05f5a2: Already exists 
2b032b8bbe8b: Already exists 
a9a5b35f6ead: Already exists 
3245b5a1c52c: Pull complete 
afa075743392: Pull complete 
9fb9f21641cd: Pull complete 
0ad7b4ea7d88: Pull complete 
734822eca0d5: Pull complete 
834c5d960979: Pull complete 
f97dc2eb9d1b: Pull complete 
3700ff49740e: Pull complete 
3b1bed89e293: Pull complete 
Digest: sha256:191e1fdaa50a08f95b0fe728ea0037b291b32944ba5fa7ced4f68fb36ca38238
Status: Downloaded newer image for cypress/browsers:chrome63
root@d301e13ff9a6:/src# whoami
root
root@d301e13ff9a6:/src# $(npm bin)/cypress version
npm info it worked if it ends with ok
npm info using npm@3.10.10
npm info using node@v6.11.1
npm info ok 
Cypress package version: 1.1.4
Cypress binary version: 1.1.4
root@d301e13ff9a6:/src# $(npm bin)/cypress run --browser chrome
npm info it worked if it ends with ok
npm info using npm@3.10.10
npm info using node@v6.11.1
npm info ok 
Warning: Cypress can only record videos when using the built in 'electron' browser.

You have set the browser to: 'chrome'

A video will not be recorded when using this browser.
  (Tests Starting)


  page
    ✓ works


  1 passing (120ms)


  (Tests Finished)

  - Tests:           1
  - Passes:          1
  - Failures:        0
  - Pending:         0
  - Duration:        0 seconds
  - Screenshots:     0
  - Video Recorded:  false
  - Cypress Version: 1.1.4


  (All Done)

root@d301e13ff9a6:/src# google-chrome --version
Google Chrome 63.0.3239.84 
root@d301e13ff9a6:/src# node node_modules/cypress/dist/Cypress/resources/app/packages/launcher/index.js 
Launcher project exports
{ [Function: init]
  update: [Function: update],
  detect: [Function: detectBrowsers] }
⛔️ please use it as a module, not from CLI
detected 1 browser
[ { name: 'chrome',
    displayName: 'Chrome',
    version: '63.0.3239.84',
    path: 'google-chrome',
    majorVersion: '63' } ]

@bahmutov
Copy link
Contributor

bahmutov commented Dec 7, 2017

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

No branches or pull requests

8 participants