-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 starts Xvfb even when running with Chrome Headless #19868
Comments
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
Activity bump. |
Have you referred to the documentation https://docs.cypress.io/guides/continuous-integration/introduction#Running-headless-tests-without-Xvfb and tried out the workaround there? Are you still using the old Cypress |
I will check it out, thanks! |
@just-jeb have you confirmed this is still happening on the latest version of Cypress? |
@MikeMcC399 As noted in the documentation, that flag is experimental. |
Unfortunately we have to close this issue due to inactivity. Please comment if there is new information to provide concerning the original issue and we can reopen. |
@nagash77 inactivity might be the wrong reason here as there has been multiple replies in the last week. |
@rooby this ticket is for a quite old version of Cypress. Since v9 of Cypress A LOT has changed in the app. As such we ask that users verify the behavior is still present in the latest version of Cypress. If you have a reproducible example of this behavior you can share in a version >12.0 please comment back here and we will be happy to investigate. |
@nagash77 Yes this is still an issue in the newer versions. The command was explicitly headless: And with
Notably:
|
@rooby Do you know where I can find information that states chrome headless doesn't need xvfb? |
|
@MikeMcC399 I wonder if we can just pass in the browser to the isNeeded function and return false if chrome and headless? Could be a good first PR for a contributor. |
That would definitely be worth investigating although @rooby stated that |
That or maybe the variable isn't spawned correctly in the process. Something that should be verified either way. |
I confirmed this issue with Cypress 12.13.0 under Ubuntu 20.04 and Node.js 18.16.0 See repo https://github.com/MikeMcC399/cy-xvfb-test Edit: Still failing in Cypress 12.16.0 |
I confirm that it fails in Cypress 12.17.2 as well. We are using Jenkins CI and Docker. The issue was more frequent in Cypress 10.10 and we recently migrated from v10 to v12. Running with ELECTRON_RUN_AS_NODE=1 and explicitly specifying --headless as in the node script below seemed to have worked for while with v10.10 however in v12.17.2 , this has re-surfaced. `
`
@navedanjum
if using docker-compose.yml , removing network_mode: host will solve the issue. |
I am also seeing this issue on Cypress 13 with Angular 17. Current BehaviorWhen running Cypress tests through Angular CLI on a Linux CI environment (GitHub Actions), Cypress is being launched twice, once with Chrome and once with Electron. This is causing unexpected behaviour:
Command Used
What's Happening
Expected BehaviorCypress should only run once with the specified browser (Chrome in this case). Environment Details
Configurationpackage.json script"e2eci": "ng e2e --configuration ci --browser chrome" angular.json configuration"e2e": {
"builder": "@cypress/schematic:cypress",
"options": {
"devServerTarget": "app:serve",
"watch": true,
"headless": false,
"browser": ""
},
"configurations": {
"ci": {
"baseUrl": "http:https://localhost:4204",
"headless": true,
"ssl": false
}
}
} angular.json::e2e contains a definition of browser to trample the defaults in Cypress code, this obviously doesn't resolve it. "browser": "" Relevant Log Output
Additional Notes
I would appreciate any insights into why this double run is occurring and how it can be prevented while still using the Angular CLI for running Cypress tests. Workarounds attempted:ELECTRON_RUN_AS_NODEI attempted to use ELECTRON_RUN_AS_NODE=1 to inhibit the xvfb behaviour but that just caused #18224 which points back to this issue. No dice. /opt/hostedtoolcache/node/20.15.0/x64/bin/npx cypress verify
2024-07-05T00:31:25.695Z cypress:cli:cli cli starts with arguments ["/opt/hostedtoolcache/node/20.15.0/x64/bin/node","/home/runner/work/[PROJECT]/[PROJECT]/frontend/node_modules/.bin/cypress","verify"]
2024-07-05T00:31:25.696Z cypress:cli NODE_OPTIONS is not set
2024-07-05T00:31:25.696Z cypress:cli:cli program parsing arguments
2024-07-05T00:31:25.699Z cypress:cli parsed cli options {}
2024-07-05T00:31:25.783Z cypress:cli verifying Cypress app
2024-07-05T00:31:25.783Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2024-07-05T00:31:25.783Z cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable
2024-07-05T00:31:25.784Z cypress:cli using environment variable CYPRESS_CACHE_FOLDER /home/runner/.cache/Cypress
2024-07-05T00:31:25.784Z cypress:cli checking environment variables
2024-07-05T00:31:25.791Z cypress:cli checking if executable exists /home/runner/.cache/Cypress/13.13.0/Cypress/Cypress
2024-07-05T00:31:25.793Z cypress:cli Binary is executable? : true
2024-07-05T00:31:25.793Z cypress:cli binaryDir is /home/runner/.cache/Cypress/13.13.0/Cypress
2024-07-05T00:31:25.793Z cypress:cli Reading binary package.json from: /home/runner/.cache/Cypress/13.13.0/Cypress/resources/app/package.json
2024-07-05T00:31:25.798Z cypress:cli Found binary version 13.13.0 installed in: /home/runner/.cache/Cypress/13.13.0/Cypress
2024-07-05T00:31:25.799Z cypress:cli could not read binary_state.json file at "/home/runner/.cache/Cypress/13.13.0/binary_state.json"
2024-07-05T00:31:25.799Z cypress:cli {}
2024-07-05T00:31:25.800Z cypress:cli is Verified ? undefined
2024-07-05T00:31:25.800Z cypress:cli force verify
2024-07-05T00:31:25.800Z cypress:cli running binary verification check 13.13.0
[STARTED] Task without title.
2024-07-05T00:31:25.803Z cypress:cli clearing out the verified version
2024-07-05T00:31:25.805Z cypress:cli Environment variable ELECTRON_RUN_AS_NODE detected, xvfb is not needed
2024-07-05T00:31:25.805Z cypress:cli needs Xvfb? false
2024-07-05T00:31:25.805Z cypress:cli spawning, should retry on display problem? false
2024-07-05T00:31:25.805Z cypress:cli disabling Electron sandbox
2024-07-05T00:31:25.805Z cypress:cli running smoke test
2024-07-05T00:31:25.805Z cypress:cli using Cypress executable /home/runner/.cache/Cypress/13.13.0/Cypress/Cypress
2024-07-05T00:31:25.805Z cypress:cli smoke test command: /home/runner/.cache/Cypress/13.13.0/Cypress/Cypress --no-sandbox --smoke-test --ping=776
2024-07-05T00:31:25.805Z cypress:cli smoke test timeout 30000 ms
2024-07-05T00:31:26.[48](https://github.com/[PROJECT]/[PROJECT]/actions/runs/9801235292/job/27064340185#step:5:49)9Z cypress:cli Smoke test failed: Error: Command failed with exit code 9: /home/runner/.cache/Cypress/13.13.0/Cypress/Cypress --no-sandbox --smoke-test --ping=776
/home/runner/.cache/Cypress/13.13.0/Cypress/Cypress: bad option: --no-sandbox
/home/runner/.cache/Cypress/13.13.0/Cypress/Cypress: bad option: --smoke-test
/home/runner/.cache/Cypress/13.13.0/Cypress/Cypress: bad option: --ping=776
at makeError (/home/runner/work/[PROJECT]/[PROJECT]/frontend/node_modules/cypress/node_modules/execa/lib/error.js:59:11)
at handlePromise (/home/runner/work/[PROJECT]/[PROJECT]/frontend/node_modules/cypress/node_modules/execa/index.js:114:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
shortMessage: 'Command failed with exit code 9: /home/runner/.cache/Cypress/13.13.0/Cypress/Cypress --no-sandbox --smoke-test --ping=776',
command: '/home/runner/.cache/Cypress/13.13.0/Cypress/Cypress --no-sandbox --smoke-test --ping=776',
exitCode: 9,
signal: undefined,
signalDescription: undefined,
stdout: '',
stderr: '/home/runner/.cache/Cypress/13.13.0/Cypress/Cypress: bad option: --no-sandbox\n' +
'/home/runner/.cache/Cypress/13.13.0/Cypress/Cypress: bad option: --smoke-test\n' +
'/home/runner/.cache/Cypress/13.13.0/Cypress/Cypress: bad option: --ping=776',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
2024-07-05T00:31:26.[49](https://github.com/[PROJECT]/[PROJECT]/actions/runs/9801235292/job/27064340185#step:5:50)0Z cypress:cli error message: /home/runner/.cache/Cypress/13.13.0/Cypress/Cypress: bad option: --no-sandbox
/home/runner/.cache/Cypress/13.13.0/Cypress/Cypress: bad option: --smoke-test
/home/runner/.cache/Cypress/13.13.0/Cypress/Cypress: bad option: --ping=776
2024-07-05T00:31:26.491Z cypress:cli detecting arch { osPlatform: 'linux', osArch: 'x64' }
2024-07-05T00:31:26.499Z cypress:cli arm uname -m result: { stdout: 'x86_64' }
[FAILED] Cypress failed to start. |
This should probably be a new issue. |
Seemed related. Felt the context may help. I shall move it to a new issue and reference this one. |
@nevercast ! Any other instance of Cypress running on machine/server ? , if you're using the shared infrastructure resources. Xvfb issues we had resolved on the past because we had number of cypress jobs ran on the same linux server and we had to ensure the dockerized cypress tests do not share resource with the hosts to get rid of it. Your issue does not seem like one I am mentioned but often other job runs leave out xvfb process running on the machine. |
If we run with chrome, can we remove xvfb dependency in the future? |
That is the request in this issue. The issue is however still open, so there is no answer to your question at the moment. |
Thank you for your reply, I'll pay attention to the progress. 😀 |
I'm experiencing this same issue, only way for us to resolve it is to go in and manually kill Xvfb processes and then rerun the tests. |
Nope, no other processes on the server. GitHub Actions is spawning a fresh runner every time. |
Did you ever open a separate issue? There is something wrong, apart from xvfb, if Cypress is being run twice. If you haven't done so already, I suggest again to open a new issue and post your GitHub Actions workflow. |
|
Thanks! Yep. That was the issue. |
It was added to the
|
Current behavior
Cypress starts
Xvfb
even when running with Chrome Headless, which causesdisplay already in use
error when running multiple Cypress processes.Desired behavior
Cypress shouldn't run
Xvfb
if run with Chrome Headless.Test code to reproduce
Xvfb
on its own).yarn --frozen-lockfile
yarn ci
Cypress Version
9.3.1
Other
I'm aware of the possibility of running
Xvfb
on my own or spawning multiple machines, but this issue shouldn't be happening in first place, because Chrome Headless doesn't requireXvfb
.The text was updated successfully, but these errors were encountered: