Git Product home page Git Product logo

Comments (26)

relnod avatar relnod commented on July 30, 2024 3

I ran into the same problem. After removing network_mode: 'host' it works. Is there a fix for this?

from cypress-docker-images.

dalgarno avatar dalgarno commented on July 30, 2024 1

I was having the same issue, and what fixed it was adding:

environment:
  - DISPLAY

to the cypress service in docker-compose.

from cypress-docker-images.

kylebebak avatar kylebebak commented on July 30, 2024 1

I hit this as well, because we were running Selenium tests on the the Circle CI server as well as Cypress tests, and by the time we ran the Cypress tests we had already started Xvfb.

Simply killing Xvfb before running cypress fixed the problem: sudo pkill Xvfb.

from cypress-docker-images.

juristr avatar juristr commented on July 30, 2024

Having the same issue when I run my docker-compose setup.

version: '3.3'

services:
  angular-app:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - '80:80'

  cypress-e2e:
    build:
      context: ./e2e
      dockerfile: Dockerfile.cypress
    depends_on:
      - angular-app
    network_mode: host

my Cypress docker file:

FROM cypress/browsers:chrome69

# set working directory
WORKDIR /usr/app-e2e

ENV PATH /usr/app-e2e/node_modules/.bin:$PATH

# install and cache app dependencies
COPY . /usr/app-e2e

RUN npm install

Also tried cypress/base as base image, but didn't change anything

from cypress-docker-images.

bahmutov avatar bahmutov commented on July 30, 2024

@juristr

let's debug this problem

We have this problem occasionally on Travis CI but not on Circle for example, so we strongly think this is due to some bugs in containers not with the logic or time outs

from cypress-docker-images.

juristr avatar juristr commented on July 30, 2024

@bahmutov Thanks for your hints. Gonna check some of them out. I'm using a setup similar to here as I need to run a docker-compose setup on CircleCI.

Basically I'm having an Angular app that's being booted and the Cypress container then runs the tests against that. Gonna check some of your debugging tips. locally on my machine it works. On CircleCI however I get the error 🤔

Creating network "project_default" with the default driver
Creating project_angular-app_1 ... 

Creating project_angular-app_1
 ⠙  Verifying Cypress can run /root/.cache/Cypress/3.1.0/Cypress
 ✖  Verifying Cypress can run /root/.cache/Cypress/3.1.0/Cypress
   
Your system is missing the dependency: XVFB

Install XVFB and run Cypress again.

Read our documentation on dependencies for more information:

https://on.cypress.io/required-dependencies

If you are using Docker, we provide containers with all required dependencies installed.
----------

Caught error trying to run XVFB: "XVFB exited with a non zero exit code.

There was a problem spawning Xvfb.

This is likely a problem with your system, permissions, or installation of Xvfb.
----------

Error: _XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE) 
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
----------

Platform: linux (Debian - 8.11)
Cypress Version: 3.1.0"
----------

Platform: linux (Debian - 8.11)
Cypress Version: 3.1.0
Exited with code 1

from cypress-docker-images.

bahmutov avatar bahmutov commented on July 30, 2024

hmm, weird, but hard for me to recreate, a complete repro would be ideal. Does this happen every time?

from cypress-docker-images.

juristr avatar juristr commented on July 30, 2024

yes. I'll try to create a small sample repo and share it on GitHub

from cypress-docker-images.

juristr avatar juristr commented on July 30, 2024

@bahmutov I have a repro repository here: https://github.com/juristr/nx-cypress-ci-setup

I can also add you (or anyone else) as a collaborator if that makes it easier to debug the issue. Locally it works just fine, when executed on CircleCI I get the error as seen here: https://circleci.com/gh/juristr/nx-cypress-ci-setup/3

Let me know if I can help

from cypress-docker-images.

bahmutov avatar bahmutov commented on July 30, 2024

@juristr I did not have time to debug the issue, but take a look at https://github.com/cypress-io/xvfb - this is the XVFB module we use to try to start the server (see #54 (comment))

Could you debug this problem in Circle by rerunning the job with SSH and maybe even editing the code in node_modules/@cypress/xvfb directly?

from cypress-docker-images.

juristr avatar juristr commented on July 30, 2024

Could you debug this problem in Circle by rerunning the job with SSH

Oh alright, didn't know I can debug CircleCI via SSH. thx, will let you know 👍

from cypress-docker-images.

spaceribs avatar spaceribs commented on July 30, 2024

I spent some time removing as many variables as I could to fix this problem, and it appears that running selenium alongside your other docker instances can cause this issue to appear.

from cypress-docker-images.

tylergets avatar tylergets commented on July 30, 2024

The problem is that when running in host mode, the X server port can be shared across cypress instances, the host machine itself, or something else (selenium). To fix we should use a nonstandard port for the xvfb instance within the container. You can also find the original X server and kill it first (in my case, Circle CI machine executor image has one.)

These issues are connected
https://github.com/cypress-io/cypress-docker-images/issues/39
cypress-io/cypress#1426
cypress-io/cypress#673
cypress-io/cypress#457

from cypress-docker-images.

jennifer-shehane avatar jennifer-shehane commented on July 30, 2024

@bahmutov Any updates here?

from cypress-docker-images.

bahmutov avatar bahmutov commented on July 30, 2024

@tylergets would you like to implement a detection for XVFB running already (probably in https://github.com/cypress-io/xvfb) and maybe a fix?

from cypress-docker-images.

davidedwards88 avatar davidedwards88 commented on July 30, 2024

Hi all. I've raised PR cypress-io/cypress#5035 containing the workaround we've used in my team for this issue. We've exposed an environment variable hook to allow us to control the XVFB port used, thereby allowing us to ensure that each of the containers participating in our parallel Cypress run does so using a different port number.

While this doesn't address the underlying issue in the way that @bahmutov's suggestion would, it may at least help others work around this problem by giving them control of the XVFB port used until such time as that fix can be implemented.

from cypress-docker-images.

bahmutov avatar bahmutov commented on July 30, 2024

we have released Cypress v3.5.0 with a timeout of 30 seconds, I hope it helps.

from cypress-docker-images.

thomasactia avatar thomasactia commented on July 30, 2024

Hi all. I've raised PR #54 containing the workaround we've used in my team for this issue.

@davidedwards88 The PR link just leads back to this page. Was it merged, or do you have a copy somewhere?

from cypress-docker-images.

davidedwards88 avatar davidedwards88 commented on July 30, 2024

@thomasactia Apologies, I hadn't realised I'd included an incorrect link in my comment. I've been able to find the PR I should have referenced, which can be found at cypress-io/cypress#5035 (I've now updated my original comment also).

As per the comments in that PR, unfortunately it went un-merged as I did not have time to address the feedback given.

from cypress-docker-images.

HartiganHM avatar HartiganHM commented on July 30, 2024

I'm running into this on the newest Cypress version (6.5.0). Any chance there's an update on a fix/workaround for this issue? Happy to provide more details as needed.

from cypress-docker-images.

CelestineKao avatar CelestineKao commented on July 30, 2024

I'm seeing this with Cypress version 6.6.0 and 6.4.0, using cypress/included:6.6.0 in CircleCI. Also happy to provide more details!

from cypress-docker-images.

CelestineKao avatar CelestineKao commented on July 30, 2024

@dalgarno's solution worked for me, ie:

environment:
  - DISPLAY

So full config for docker-compose for cypress is something like:

version: "3"
services:
  cypress:
    build:
      context: path/for/context
      dockerfile: path/to/Dockerfile
    # So cypress can reach localhost
    network_mode: host
    environment:
      # Required to prevent an issue with cypress complaining about xvfb
      # See https://github.com/cypress-io/cypress-docker-images/issues/54#issuecomment-569427367
      DISPLAY:
    # Needed so chromium doesn't crash
    # See https://github.com/cypress-io/cypress/issues/350
    ipc: host

from cypress-docker-images.

CS-Tao avatar CS-Tao commented on July 30, 2024

I have a temporary solution to solve server already running caused by network_mode: host in my project.

Check xvfb port and generate cypress-xvfb lock file before running cypress

prepare_xvfb () {
  # delete all cypress-xvfb lock file
  [ -f /tmp/.X*-lock ] && rm -f /tmp/.X*-lock

  local display_num=99
  local loop=true

  while [ $loop == 'true' ]
  do
    # xvfb port
    if [ $display_num -ge 100 ]; then
      local xvfb_port="6$display_num"
    else
      local xvfb_port="60$display_num"
    fi
    # generate cypress-xvfb lock file
    nc -z 127.0.0.1 "$xvfb_port" || local occupied=false
    if [[ "$occupied" == "false" ]]; then
      local loop=false
    else
      echo "[ Info ] xvfb display number :${display_num} was occupied. Check next"
      echo "<my project> placeholder" > "/tmp/.X${display_num}-lock"
      let display_num++
    fi
  done
  echo "[ Info ] xvfb will use display :${display_num}."
}

Cypress version in my project is 3.8.0 and @cypress/xvfb version is 1.2.4. Cypress-xvfb lock file used in https://github.com/cypress-io/xvfb/blob/0051191e4953a2a922086dcdc5c4aae3aecfe5b1/index.js#L128

from cypress-docker-images.

Borda avatar Borda commented on July 30, 2024

We are seening it recently in CI with GHA large runners.. 😕

from cypress-docker-images.

MikeMcC399 avatar MikeMcC399 commented on July 30, 2024

@Borda

We are seening it recently in CI with GHA large runners.. 😕

Do you have details about which Cypress Docker image you are using, which version of Cypress and what your host environment is?

Could you provide up-to-date logs?

from cypress-docker-images.

MikeMcC399 avatar MikeMcC399 commented on July 30, 2024

Closing due to inactivity.

from cypress-docker-images.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.