cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.62k stars 3.15k forks source link

cypress run times out waiting for the browser to connect #3310

Closed achelonmm closed 1 year ago

achelonmm commented 5 years ago

Current behavior:

I have an automated release for my test suite. It consists of 8 specs that are executed one after the other.

A few weeks back, one of the specs got stuck and I had to force a shutdown of the release. After that, on every release, after the first spec is run, Cypress fails to open the browser or find it or something and the tests fail.

This is the error I'm getting:

2019-02-04T02:11:09.1221261Z Timed out waiting for the browser to connect. Retrying...
2019-02-04T02:11:39.1105823Z 
2019-02-04T02:11:39.4465327Z Timed out waiting for the browser to connect. Retrying again...
2019-02-04T02:12:09.4535443Z 
2019-02-04T02:12:10.1352111Z The browser never connected. Something is wrong. The tests cannot run. Aborting...

I have deleted the Virtual Machine I use for the test and created it again, changed versions of Chrome, changed versions of Cypress and nothing changes. If I enter the VM with the release user, and use the command manually on a command line, it works, but in the automated release doesn't.

I'm currently out of ideas.

Desired behavior:

Every spec should run correctly as it did before

Versions

Cypress 3.1.4 and 3.1.5 Chrome 72.0.3626 VSTS for release automation

Saranya-Mohandas commented 3 years ago

Same issue. Headless mode failing with both electron and chrome. Please share workaround. Thanks!

lasithdilshan20 commented 3 years ago

@Saranya-Mohandas, Are you doing via the execution on CI / CD?

Elizaveta1105 commented 2 years ago

@lasithdilshan20 @Saranya-Mohandas Hello! I have the same issue now. Did you resolve it?

Bakuutin commented 2 years ago

For me, the actual error was running out of memory inside the CI job. And adding "numTestsKeptInMemory": 0 to cypress.json solved the issue.

joshkel commented 2 years ago

I'm seeing a similar problem. I have a simple set of two Cypress .spec files; the first spec works, while the second fails with "Timed out waiting for the browser to connect."

I tried the workarounds mentioned here ("numTestsKeptInMemory": 0, adding --browser chrome instead of Electron, and xvfb-run cypress --headed --browser chrone, checking that localhost is in /etc/hosts), but they didn't help. I ran with DEBUG=cypress:*, and nothing jumped out at me, although that output is quite verbose, so I could be missing something.

Interestingly, my Windows 11 PC demonstrates the same problem when I run locally with cypress run, so at least I can reproduce the problem locally, under an environment I can control. I'm not sure if I'll have time to do a deep dive into what's causing it, though.

shaikhalid commented 2 years ago

I'm seeing a similar problem. I have a simple set of two Cypress .spec files; the first spec works, while the second fails with "Timed out waiting for the browser to connect."

  • GitLab CI
  • Cypress 9.3.1
  • cypress/browsers:node14.17.0-chrome91-ff89 Docker container

I tried the workarounds mentioned here ("numTestsKeptInMemory": 0, adding --browser chrome instead of Electron, and xvfb-run cypress --headed --browser chrone, checking that localhost is in /etc/hosts), but they didn't help. I ran with DEBUG=cypress:*, and nothing jumped out at me, although that output is quite verbose, so I could be missing something.

Interestingly, my Windows 11 PC demonstrates the same problem when I run locally with cypress run, so at least I can reproduce the problem locally, under an environment I can control. I'm not sure if I'll have time to do a deep dive into what's causing it, though.

Hey I am having the exact same issue and cypress 9, but I am able to tests locally on my machine without any problems. Did you manage to find any solution to this ?

joshkel commented 2 years ago

Did you manage to find any solution to this ?

@shaikhalid I have not.

dawid-bobowski commented 2 years ago

Any progress on that? I have the same issue with Cypress 8.3.0 on Jenkins.

OndeVai commented 2 years ago

Same here!

damonhnz commented 2 years ago

I was having this issue about 50% of the time running on a mac (but not at all on Linux) using Cypress 10.3 and Electron browser. Disabling the GPU has fixed it for me.

export ELECTRON_EXTRA_LAUNCH_ARGS=disable-gpu
testingtrail commented 1 year ago

Github Actions cypress/browsers:node12.18.0-chrome83-ff77 "cypress": "^9.5.1"

I am running github actions, and In my case I changed some files from This.js to this.js and when committing to Github the files were not changed to lowercase which other cypress files were calling as import base from './this'; so I manually changed the files in the git repository to be lowercase, and then my workflow worked. It may be silly things like these that cause those errors.

raghavharness commented 1 year ago

We were facing same issue with cypress 12.5.0 and Electron 106. The issue for us was coming from XDG_CONFIG_HOME env variable. It was not getting set and it seems this gets used by electron. We tried to set it manually XDG_CONFIG_HOME=$HOME/.config and things started working correctly. Sharing here if it helps anyone.

w4dd325 commented 1 year ago

My anti-virus was causing this issue for me. Once I disabled it, the issue stopped.

warrensplayer commented 1 year ago

Thanks for the feedback and ideas for how you were able to solve this type of issue. If anyone comes across this issue again. Please file a new issue and include a reproduction. Thanks!

matheuspellegrini commented 1 year ago

I've faced this same issue and after a long research I've identified that my problem is related to webpack build, so I've tried to build(npm run build) and my webpack run out of memory(WSL), I've 32GB of RAM and this still happends, so I just run this export NODE_OPTIONS=--max_old_space_size=8192 and cypress work again, took me some months to discover this as cypress doesn't stop or show errors related to webpack build(just when succeed). Hope I can help you(I've never found that related solution).

sangeeta-chakalabbi commented 1 year ago

I see the above issue again.. with cypress 12.17.1

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...

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

On running with DEBUG option, I get to see the following

2023-07-16T21:16:43.732Z cypress:server:browsers browsers.kill called with no active instance 2023-07-16T21:16:43.734Z cypress:server:browsers getBrowserLauncher { browser: { name: 'electron', channel: 'stable', family: 'chromium', displayName: 'Electron', version: '106.0.5249.51', path: '', majorVersion: 106, isHeadless: true, isHeaded: false } } 2023-07-16T21:16:43.734Z cypress:server:browsers opening browser { name: 'electron', channel: 'stable', family: 'chromium', displayName: 'Electron', version: '106.0.5249.51', path: '', majorVersion: 106, isHeadless: true, isHeaded: false } 2023-07-16T21:16:43.735Z cypress:server:browsers:electron open { browser: { name: 'electron', channel: 'stable', family: 'chromium', displayName: 'Electron', version: '106.0.5249.51', path: '', majorVersion: 106, isHeadless: true, isHeaded: false }, url:

nagash77 commented 1 year ago

@sangeeta-chakalabbi please open a new issue with a reproducible example and the Cypress team will be happy to investigate.

fritzfelix commented 1 year ago

I have the same issue since we moved from yarn to pnpm. @sangeeta-chakalabbi Are you using pnpm by any chance?

mbourd commented 10 months ago

The problem is still present:

ℹ 「wds」: Project is running at http://localhost:36559/webpack-dev-server/
ℹ 「wds」: webpack output is served from /__cypress/src
ℹ 「wds」: Content not from webpack is served from /home/new/projects/cp1-front

====================================================================================================

  (Run Starting)

  │ Cypress:        13.3.0                                                                         
  │ Browser:        Electron 114 (headless)                                                        
  │ Node Version:   v16.14.0 (/home/new/.nvm/versions/node/v16.14.0/bin/node)                      
  │ Specs:          89 found (...)                                                    
  │ Searched:       src/**/*.cy.tsx                                                                
  │ Experiments:    experimentalMemoryManagement=true

  Running:  Features/Audit/File/FileAuditRender.cy.tsx                                     (1 of 89)
ℹ 「wdm」: wait until bundle finished: /__cypress/src/index.html

Timed out waiting for the browser to connect. Retrying...
ℹ 「wdm」: Compiled with warnings.
There was an error reconnecting to the Chrome DevTools protocol. Please restart the browser.

TypeError: Cannot read properties of undefined (reading 'webSocketDebuggerUrl')
    at _._fetchDebuggerURL (<embedded>:2502:520933)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _._start (<embedded>:2502:520232)

However the issue occur only with "Electron 114+" (headless) When I run the command: npx cypress run --component I also have many tests (more than 450)

With the other browsers like Chrome, seems working.

Can you please fix this issue ?

jwedel commented 10 months ago

We are also experienced that.

Very weird... I tried debugging and changing from localhost to 127.0.0.1 / 0.0.0.0 on cypress and dev server side but with no luck.

jerkovicl commented 10 months ago

I have also experienced problems with running on Gitlab CI with image: cypress/included:cypress-13.3.1-node-20.6.1-chrome-116.0.5845.187-1-ff-117.0-edge-116.0.1938.76-1, getting same error

image

jennifer-shehane commented 10 months ago

Please open new issues, filling out the issue template, describing your issues.