cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.48k 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

jennifer-shehane commented 5 years ago

Is there any way to clear the App Data or maybe uninstall / reinstall Cypress altogether?

achelonmm commented 5 years ago

Is there any way to clear the App Data or maybe uninstall / reinstall Cypress altogether?

We did. We uninstalled and reinstalled and then uninstalled again and installed previous version. After that we uninstalled and reinstalled. We even deleted the VM and created it again new, and nothing changed.

jennifer-shehane commented 5 years ago

Are these tests able to run when opened in Electron locally?

Could you provide the test code - for spec 1 + spec 2?

Likely something changed a few weeks ago that is causing this.

achelonmm commented 5 years ago

If I run them locally, they open both in Electron and in Chrome. In fact, if I enter the VM and run the same command manually it works.

import { documentManagementModule } from "../../id-collection"

const setDate = (datePicker, date) => { 
    datePicker.wait(3000)

    let dels = '{selectall}{del}';

    datePicker.type('${dels}${date}')
    cy.wait(4000)
}

describe('Document Management - Search Document', function () {
    after(function() {
        cy.reload(true)

        cy.url()
            .should('contain',Cypress.env('url_base_comparar'))

        cy.get(documentManagementModule.common.user_badge_topmenu)
            .click()

        cy.get(documentManagementModule.common.user_badge_popup)
            .should('exist')

        cy.get(documentManagementModule.common.user_badge_logout)
            .click()
            .wait(2000)
    })

    it('TC1163 - check functionality of Document List button', function () {
        cy.reload(true)

        cy.get(documentManagementModule.DMcommon.menu_item_UploadDocument)
            .should('be.visible')

        cy.get(documentManagementModule.DMcommon.menu_item_UploadDocument)
            .click()

        cy.get(documentManagementModule.searchDocument.patientSearch)
            .should('be.visible')

        cy.url()
            .should('contain', 'new')

        cy.get(documentManagementModule.DMcommon.menu_item_ListDocuments)
            .should('be.visible')

        cy.get(documentManagementModule.DMcommon.menu_item_ListDocuments)
            .click()

        cy.url()
            .should('contain','search')
    })

    it('TC1205 - check there are no documents when page loads and the filter window is open', function () {
        cy.visit('app/search')

        cy.get('body')
            .type('{esc}',{force:true})

        cy.get(documentManagementModule.searchDocument.noResults)
            .should('exist')
    })

    it('TC1207 - check functionality of select all', function () {
        cy.visit('app/search')

        cy.get('body')
            .type('{esc}',{force:true})

        cy.get(documentManagementModule.searchDocument.noResults)
            .should('exist')

        cy.get(documentManagementModule.searchDocument.medicalServices_Input)
            .wait(4000)
            .type('cardio{enter}',{ force: true })

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('contain','CARDIOLOGÍA')

        cy.get(documentManagementModule.searchDocument.selectCounter)
            .should('contain','0')

        cy.get(documentManagementModule.searchDocument.selectAll)
            .click({force:true})

        cy.get(documentManagementModule.searchDocument.selectCounter)
            .should('contain','52')
    })

    it('TC1206 - chech functionality of filter button', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.patientSearchComponent)
            .should('exist')

        cy.get(documentManagementModule.searchDocument.btnFilters)
            .click()

        cy.get(documentManagementModule.searchDocument.patientSearchComponent)
            .should('not.exist')

        cy.get(documentManagementModule.searchDocument.btnFilters)
            .click()

        cy.get(documentManagementModule.searchDocument.patientSearchComponent)
            .should('exist')
    })

    it('TC1184 - search by patient', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.patientSearchComponent)
            .type(Cypress.env('patient'),{ force: true })

        cy.get(documentManagementModule.searchDocument.patient_search_result)
            .should('contain',Cypress.env('patient'))
            .click()

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('contain',Cypress.env('patient'))
    })

    it('TC1185 - search by issuer', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.issuers_Input)
            .wait(4000)
            .type('adeslas{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('not.contain','Sin resul')
    })

    it('TC1203 - search by document date', function () {
        cy.visit('app/search')

        setDate(cy.get(documentManagementModule.searchDocument.documentDateStart), '01/01/2018')

        cy.get(documentManagementModule.searchDocument.helper_documentDateEnd)
            .should('contain','rellenar también')

        setDate(cy.get(documentManagementModule.searchDocument.documentDateEnd), '01/01/2017')

        cy.get(documentManagementModule.searchDocument.helper_documentDateEnd)
            .should('contain','debe ser mayor')

        setDate(cy.get(documentManagementModule.searchDocument.documentDateEnd), '07/11/2018')

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('contain','07/11/2018')
    })

    it('TC1204 - search by publish date', function () {    
        cy.visit('app/search')

        setDate(cy.get(documentManagementModule.searchDocument.publishedDateStart), '01/01/2018')

        cy.get(documentManagementModule.searchDocument.helper_publishedDateEnd)
            .should('contain','rellenar también')

        setDate(cy.get(documentManagementModule.searchDocument.publishedDateEnd), '01/01/2017')

        cy.get(documentManagementModule.searchDocument.helper_publishedDateEnd)
            .should('contain','debe ser mayor')

        setDate(cy.get(documentManagementModule.searchDocument.publishedDateEnd), '07/11/2018')

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('contain','07/11/2018')
    })

    it('TC1186 - search by medical services', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.medicalServices_Input)
            .wait(4000)
            .debug()
            .type('admi{enter}alerg{enter}qui{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.medicalServices_Values)
            .should('contain','3 seleccionados')     

        cy.get(documentManagementModule.searchDocument.documentName)
            .click()

        cy.get(documentManagementModule.searchDocument.medicalServices_Input)
            .type('qui{enter}alerg{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.medicalServices_Values)
            .should('contain','ADMISIONP')

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('contain','ADMISIÓN')
    })

    it('TC1187 - search by document name', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.documentName)
            .type('UDA',{ force: true })

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.helper_documentName)
            .should('contain','al menos 4')

        cy.get(documentManagementModule.searchDocument.documentName)
            .clear()

        cy.get(documentManagementModule.searchDocument.documentName)
            .type('BUDA',{ force: true })

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('not.contain','Sin resultados')
    })

    it('TC1217 - search by category', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .wait(4000)
            .type('tipos{enter}acre{enter}ident{enter}local{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.categories_Values)
            .should('contain','4 seleccionados')   

        cy.get(documentManagementModule.searchDocument.documentTypes_Input)
            .type('empa{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Values)
            .should('contain','EMPADRONAMIENTO')

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .type('local{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.categories_Values)
            .should('contain','3 seleccionados')   

        cy.get(documentManagementModule.searchDocument.documentTypes_clear_button)
            .click()

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .type('{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Input)
            .type('dni{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Values)
            .should('contain','DNI')

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .type('ident{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.categories_Values)
            .should('contain','2 seleccionados') 

        cy.get(documentManagementModule.searchDocument.documentTypes_clear_button)
            .click()

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .type('{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Input)
            .type('derecho{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Values)
            .should('contain','DOCUMENTO DE DERECHO')

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .type('acre{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.categories_Values)
            .should('contain','TIPOS FLORENCE')  

        cy.get(documentManagementModule.searchDocument.documentTypes_clear_button)
            .click()

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .type('{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Input)
            .type('alta{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Values)
            .should('contain','ALTA VOLUNTARIA')

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('contain','ALTA VOLUNTARIA')
    })

    it('TC1218 - search by document type', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.documentTypes_Input)
            .wait(4000)
            .type('alta{enter}derecho{enter}dni{enter}empa{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Values)
            .should('contain','4 seleccionados')

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .type('tipos{enter}acre{enter}local{enter}iden{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.categories_Values)
            .should('contain','4 seleccionados') 

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('not.contain','Sin resulta')
    })

    it('TC1221 - search by clinical act type', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.clinicalActTypes_Input)
            .wait(4000)
            .type('inter{enter}imagen{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.clinicalActTypes_Values)
            .should('contain','2 seleccionados')

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('contain','TORAX')
    })

    it('TC1222 - search by clinical act', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.clinicalActs_Input)
            .wait(4000)
            .type('13000023 - Densi{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.clinicalActTypes_Input)
            .wait(4000)
            .type('inter{enter}imagen{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.clinicalActs_Values)
            .should('not.exist')

        cy.get(documentManagementModule.searchDocument.clinicalActs_Input)
            .type('13000023 - Densi{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.patientSearchComponent)
            .type(Cypress.env('patient'),{ force: true })

        cy.get(documentManagementModule.searchDocument.patient_search_result)
            .should('contain',Cypress.env('patient'))
            .click()

        cy.get(documentManagementModule.searchDocument.clinicalActs_Input)
            .type('13000023 - Densi{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.clinicalActs_Values)
            .should('contain','DENSITOMETRIA')

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('contain','DENSITOMETRIA')
    })

    it('TC1223 - search by clinical act code', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.clinicalActCode)
            .type('13000023',{ force: true })

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.results_list)
            .should('contain','13000023')
    })

    it('TC1224 - check functionality of CLEAN button', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.patientSearchComponent)
            .type(Cypress.env('patient'),{ force: true })//1043319

        cy.get(documentManagementModule.searchDocument.patient_search_result)
            .should('contain',Cypress.env('patient'))
            .click()

        cy.get(documentManagementModule.searchDocument.documentName)
            .type('Test name',{ force: true })
            .wait(4000)

        cy.get(documentManagementModule.searchDocument.medicalServices_Input)
            .type('admisi{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.issuers_Input)
            .type('adeslas{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.medicalServices_Input)
            .type('{esc}')

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .type('florence{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Input)
            .type('alta{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.clinicalActTypes_Input)
            .type('imagen{enter}{esc}')

        cy.get(documentManagementModule.searchDocument.documentTypes_Input)
            .type('{esc}')

        cy.get(documentManagementModule.searchDocument.clinicalActTypes_Input)
            .type('{esc}')

        cy.get(documentManagementModule.searchDocument.clinicalActs_Input)
            .type('densitometria{enter}{esc}',{forced:true})

        cy.get(documentManagementModule.searchDocument.clinicalActCode)
            .type('13000023',{ force: true })

        setDate(cy.get(documentManagementModule.searchDocument.documentDateStart), '01/04/2018')

        setDate(cy.get(documentManagementModule.searchDocument.documentDateEnd), '30/04/2018')

        setDate(cy.get(documentManagementModule.searchDocument.publishedDateStart), '01/04/2018')

        setDate(cy.get(documentManagementModule.searchDocument.publishedDateEnd), '30/04/2018')

        cy.get(documentManagementModule.searchDocument.cleanButton)
            .click()

        cy.get(documentManagementModule.searchDocument.patientSearchComponent)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.documentName)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.medicalServices_Input)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.issuers_Input)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.categories_Input)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.documentTypes_Input)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.clinicalActTypes_Input)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.clinicalActs_Input)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.clinicalActCode)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.documentDateStart)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.documentDateEnd)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.publishedDateStart)
            .should('be.empty')

        cy.get(documentManagementModule.searchDocument.publishedDateEnd)
            .should('be.empty')

        cy.get('body')
            .type('{esc}',{force:true})
    })

    it('TC1219 - click on a document and check its opened and data is correct', function () {
        cy.visit('app/search')

        cy.get(documentManagementModule.searchDocument.patientSearchComponent)
            .type(Cypress.env('patient'),{ force: true })

        cy.get(documentManagementModule.searchDocument.patient_search_result)
            .should('contain',Cypress.env('patient'))
            .click()

        cy.get(documentManagementModule.searchDocument.documentName)
            .type('ENALG')

        cy.get(documentManagementModule.searchDocument.searchButton)
            .click()

        cy.get(documentManagementModule.searchDocument.btnView_result)
            .click()

        cy.url()
            .should('contain','/view/')

        cy.get(documentManagementModule.searchDocument.patientSearch)
            .should('contain','FELICISIMO ANGEL')

        cy.get(documentManagementModule.searchDocument.categoryInput)
            .should('contain','TIPOS FLORENCE')

        cy.get(documentManagementModule.searchDocument.serviceInput)
            .should('contain','ALERGOLOGÍA')

        cy.get(documentManagementModule.searchDocument.documentTypeInput)
            .should('contain','INFORME ENDOSCOPIA')
    })
})

The weird thing is that it doesn't seem to be related to the spec as I tried changing them (order and so) and it didn't change a thing. First spec always executes perfectly, second one can't open browser anymore.

Apart from that, the only thing we do is log in:

it('TC1317 - Check that login works', function () {
    cy.visit('')

    cy.get('#btnLoginOauth')
        .click()

    cy.get("#dniField")
        .type(Cypress.env('user'),{force:true})

    cy.get("#passwordField")
        .type(Cypress.env('pwd'),{force:true})

    cy.get("#btnLogin")
        .click()

    cy.wait(5000)
})
jennifer-shehane commented 5 years ago

Perhaps try to collect some more logging information during cypress run https://on.cypress.io/debugging#Print-DEBUG-logs

jennifer-shehane commented 5 years ago

You may also want to be aware of this issue - where the click does not execute in after hooks if a test fails: https://github.com/cypress-io/cypress/issues/2831 but I don't think this is related to your problem.

achelonmm commented 5 years ago

You may also want to be aware of this issue - where the click does not execute in after hooks if a test fails: #2831 but I don't think this is related to your problem.

Yeah, I've been dealing with this too, but it's not related to my problem as the first spec, which in my case just tries to log in, log out and make an incorrect login, works perfectly and it closes the browser. And the next spec doesn't even do a click because the browser never opens.

I'm checking 2831 anyway, thanks!

Will try to DEBUG and get extra information.

Just a set DEBUG=cypress:* would work or is it better to go for set DEBUG=cypress:launcher?

achelonmm commented 5 years ago

Hello,

I have tried using DEBUG=cypress:*, however, didn't get any additional information, as the logs do not include the debugging information in the console, and if I execute everything manually, it works perfectly.

Any other idea or workaround? Is there a way to log in a file everything printed by DEBUG=cypress:*?

jennifer-shehane commented 5 years ago

I think you're going to have to try to narrow down the test code base to find the core issue. So, cut out half of test code, does it still fail. Try half of that code, etc until you get it to the smallest amount of code to run to reproduce.

@bahmutov - you have any leads or suggestions? I know you worked with VSTS some.

devsh4 commented 5 years ago

@jennifer-shehane I face the same issue (intermittently). With cypress version 3.1.5. For earlier versions it use to work just fine.

Running my test suite locally using npx cypress run (Electron 59) sometimes works and sometimes it doesn't and fails before running the first test.

image

Moin-A commented 5 years ago

I too got the same error, the first two specs are running properly, However from the third spec onwards I am gettin the error :

Screenshot 2019-03-23 at 8 54 20 PM
devsh4 commented 5 years ago

I found the cause of that issue. It seems like while starting, cypress threw an error which didn't allow the headless browser to fetch the URL (baseUrl in cypress.json) because the base URL had auth credentials and there were a couple of other URL's mentioned under env (which were cross domain) which my tests needed to access. This was the primary issue.

Removed baseUrl altogether and I created a variable under 'env' (for all the URL's) and then it worked fine. Looks like there is CORS related bug, where cypress cannot connect to electron while reading the baseUrl value from cypress.json which further has multiple urls (cross-domain) mentioned elsewhere in the same file.

jennifer-shehane commented 5 years ago

@devsh4 See this issue - it is what you are describing https://github.com/cypress-io/cypress/issues/1598

Pavel-Husakouski commented 5 years ago

I have the very same issue. Cypress version 3.1.0. There is no auth credential in the baseUrl. Cypress fails from time to time, about one of 10 times is failed.

cbernardes commented 5 years ago

Thanks @jennifer-shehane for trying to support, but I am having the same issue and all the suggestions implies try-error attempt. Here is the log I have:

We encountered an unexpected error talking to our servers.
Because you passed the --parallel flag, this run cannot proceed because it requires a valid response from our servers.
The --group flag you passed was: web
The --ciBuildId flag you passed was: 3082
The server's response was:
StatusCodeError: 503
{
  "error": "timed out creating run"
}

and it looks like a failure of cypress to orchestrate parallel request or even allocate diff servers/machines to it.

jbpallingayan commented 4 years ago

Were experiencing this right now. Is there any fix for this?

cbernardes commented 4 years ago

There is a workout around to fix this problem. You can overwrite their values reseting the env variable API_RETRY_INTERVALS. In my case I added to my CI/CD pipeline the following configuration:

Name: API_RETRY_INTERVALS
Value: 5000,5000,5000,10000,5000,5000,5000,10000

It means the Cypress will retry every 5 seconds 3 times, then 10 seconds and so on. The number of retries are exactly the length of your value list.

Pavel-Husakouski commented 4 years ago

Looks like headless electron works without that issue. @cbernardes Could you explain that magic ?

cbernardes commented 4 years ago

Hey @Pavel-Husakouski it is not magic. It is just the way they have built, I hope intentionally, their middleware. In my case it was hanging-out on the first try only, but it was enough to delay my CI/CD. After digging through their code I found this solution :D.

openSource <3.

Pavel-Husakouski commented 4 years ago

Actually, all our tests are failed because of this issue. Cypress tries to connect per every test and fails - about twenty times "The browser never connected. Something is wrong. The tests cannot run. Aborting..." We switched to headless electron because looks like it works a bit better. However, I don't have enough statistic to make any serious judgement.

cbernardes commented 4 years ago

@Pavel-Husakouski this is only necessary when you run your tests in parallel. This request is exactly to know which suite to pull from the queue. Said so, I would strongly encourage you to run your CI/CD with electron. If this is happening when you are running your tests locally, I would say you are having the wrong approach. They have a very good dashboard to help you with your tests execution and this don't require the API request which triggers the error referenced in this page issue.

GettinDatFoShow commented 4 years ago

I was experiencing this error while using angular cli for the server and the electron browser. I think the problem was that the live-reload server was trying to reload the application during the process of the cypress testing. When I serverd the code with these flags: ng serve --liveReload=false --watch=false, then it worked perfectly. Hopefully this helps some.

Pavel-Husakouski commented 4 years ago

I think the problem was that the live-reload server was trying to reload the application during the process of the cypress testing. When I served the code with these flags: ng serve --liveReload=false --watch=false, then it worked perfectly. Hopefully this helps some.

That's interesting. However, we don't use any live reload under Cypress. Moreover, we face the issue under the production environment. Anyway, electron works much better.

mingyixu commented 4 years ago

I too got the same error on cypress 4.1.0, auto execution, I run CI/CD with electron, but 10% can got this error.

suresh-cg commented 4 years ago

We are also facing same issue , the fist spec execution is passed and remaining spec file execution status results in failure due to time out issue.continuous failure in headless and test runner too.unable to invoke the electron browser from second spec execution.Tried out with all specified options ,it's invain.

Issue can be reproducible with cypress 3.4.1 ,3.8.3 as well as v4.0.0 on electron . Looking forward for further resolution .

mdorda commented 4 years ago

Same issue here. Everything works like a charm on MacOS, but on our system server with Debian Stretch, google-chrome-stable 79, node 12.16.1 and npm 6.14.4 it does not work. It is 100% cypress error, because I tried the following versions:

ConstantineSF commented 4 years ago

I try to run test in headless mode, and I'm using base url, and my tests return error with:

Timed out to connect to browser, 

after I try to use Chrome headless, it helped for me

npx cypress run --browser chrome --headless --spec
san-slysz commented 4 years ago

Just tested upgrading to v4. Also producing it within our pipeline (alpine linux). Produced calling Chrome or Electron. Locally (cypress open or run) on an ubuntu it's ok, strangely enough. We're going back to v3 :(.

We actually get 1 file ok, and then 2nd file fails (stopping the pipeline). image

MariyaQA commented 4 years ago

Cypress: 4.3.0 same issue - after first spec is running well, the next one is showing Time out waiting error, when use cypress run.
2020-04-14_1051

But @rockthis13 solution is working for me too, thank you)

npx cypress run --browser chrome --headless

jennifer-shehane commented 4 years ago

I think this new onError is not a function error may be due to the changes in https://github.com/cypress-io/cypress/pull/6610. Although this is not related to why the browser is not connecting in the first place and does not address the original issue - just a newer error being thrown since 4.2.0 that should not be.

san-slysz commented 4 years ago

I indeed added code to the impacted branch, plugin/index file lately to handle baseUrl: a switch case based on a 'platform' --env. variable. This allow us to get the right baseUrl depending on the tested env. We fallback to a default value (dev localhost:xxxx URL) if platform id not defined. Maybe that code is what caused the connection matter to start with. I'm in OOO for several weeks, but I'll try to check for that theory when back at work and let u know.

alastair-todd commented 4 years ago

Same with headless Chrome. Runs fine with Electron. Using cypress/browsers:chrome69 on AWS Code Pipeline

image

san-slysz commented 4 years ago

Hi, So last time I had an OK master, and a KO branch. I took a new branch from my OK master and just executed the 3.4 to 4.3 upgrade. This works fine. So indeed, as stated by @jennifer-shehane the update did not trigger the problem for us. I wil re-introduce the remaining cypress code I added to the KO branch progressively and let you know what part triggered the issue for us.

truyenkv commented 3 years ago

I use "while" command then my Test Case can't connect with any browser. Anyone can give me some solutions for this case?

lukeapage commented 3 years ago

I got this recently during a upgrade to v5.

Running with DEBUG=cypress:* env variable I compared the logs before a successful transition to a new spec and one that failed. I spotted that the failing logs did not feature a log that the plugin event before browser launch was resolved. Then I traced back to the previous cypress:server:plugin logs and found a after screenshot plugin event that never returned.. it seems I had made a typo that meant a plugin didn’t respond. Fixing that fixed the issue. It would be nice if cypress warned if plugin events take more than 20 seconds. Including this here in case it helps someone else debug this problem in their own case.

yuriV7 commented 3 years ago

Actual for v5.2 As I understand, Cypress sometime can't connect due to some Errors which couldn't be handled Have multiple Test runnings on Feature branches and have such a "Connection" problem sometimes

Can't connect to Chrome but works with Firefox

tomas-cs commented 3 years ago

@jennifer-shehane , is there any progress on this please? The issue is there from Feb 2019. The question which you asked and on which you set the label "stage: needs information" was answered the very next day - Feb 22, 2019, and the label is still here.

majco333 commented 3 years ago

We have the same problem last 2-3 weeks (Chrome + run on Azure Devops Self-Hosted agents).

Running all the tests will kill out machine for self-hosted Azure Agents. Can you help us? Which would help you to better identify the problem?

Output from debug console:

2020-11-19T09:58:20.1270856Z **Timed out waiting for the browser to connect. Retrying...**
2020-11-19T09:58:20.1271548Z 2020-11-19T09:58:20.095Z cypress:server:run waiting for socket to connect and browser to launch...
2020-11-19T09:58:20.1272623Z 2020-11-19T09:58:20.095Z cypress:server:run waiting for socket connection... { id: 'derj6' }
2020-11-19T09:58:20.1273078Z 2020-11-19T09:58:20.095Z cypress:server:run setting Chrome properties { shouldWriteVideo: false }
2020-11-19T09:58:20.1274831Z 2020-11-19T09:58:20.095Z cypress:server:open_project resetting project state, preparing to launch browser chrome for spec { name: 'features\\invoicing\\base\\email.feature', relative: 'cypress\\e2e\\features\\invoicing\\base\\email.feature', absolute: 'D:/agents/esw-01/_work/r11/a/E2E_Tests/cypress/e2e/features/invoicing/base/email.feature', specType: 'integration' } options { automationMiddleware: { onAfterResponse: [Function: onAfterResponse] }, projectRoot: 'D:\\agents\\esw-01\\_work\\r11\\a\\E2E_Tests', onWarning: [Function] }
2020-11-19T09:58:20.1276477Z 2020-11-19T09:58:20.095Z cypress:server:project resetting project instance D:\agents\esw-01\_work\r11\a\E2E_Tests
2020-11-19T09:58:20.1276940Z 2020-11-19T09:58:20.095Z cypress:proxy:http:util:buffers resetting buffers
2020-11-19T09:58:20.1277254Z 2020-11-19T09:58:20.095Z cypress:server:server Setting remoteAuth undefined

...

2020-11-19T09:58:30.0626408Z 2020-11-19T09:58:30.061Z cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
2020-11-19T09:58:30.0627110Z ┌─────────┬───────────┬──────────────┬────────────────────────────────────────────────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
2020-11-19T09:58:30.0628100Z │ (index) │   group   │ processCount │                            pids                            │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
2020-11-19T09:58:30.0629837Z ├─────────┼───────────┼──────────────┼────────────────────────────────────────────────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
2020-11-19T09:58:30.0630457Z │    0    │ 'plugin'  │      1       │                          '14560'                           │     0      │      0.21      │  518.65  │    353.69    │   602.35    │
2020-11-19T09:58:30.0630971Z │    1    │  'other'  │      12      │ '25244, 23976, 18084, 29176, 26884, 9352 ... 6 more items' │    10.7    │      0.5       │  305.74  │    91.46     │   307.82    │
2020-11-19T09:58:30.0631682Z │    2    │ 'cypress' │      1       │                          '13848'                           │    0.23    │      0.45      │  150.66  │    152.75    │   165.25    │
2020-11-19T09:58:30.0632097Z │    3    │  'TOTAL'  │      14      │                            '-'                             │   10.94    │      5.37      │  975.05  │   1092.71    │   1338.12   │
2020-11-19T09:58:30.0632560Z └─────────┴───────────┴──────────────┴────────────────────────────────────────────────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘
2020-11-19T09:58:45.0124591Z 2020-11-19T09:58:45.011Z cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 60939 }
2020-11-19T09:58:45.1372793Z 2020-11-19T09:58:45.011Z cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 60940 }
2020-11-19T09:58:53.9130048Z 2020-11-19T09:58:53.907Z cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
2020-11-19T09:58:53.9377310Z ┌─────────┬───────────┬──────────────┬────────────────────────────────────────────────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
2020-11-19T09:58:53.9901715Z │ (index) │   group   │ processCount │                            pids                            │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
2020-11-19T09:58:54.0010860Z ├─────────┼───────────┼──────────────┼────────────────────────────────────────────────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
2020-11-19T09:58:54.0196565Z │    0    │ 'plugin'  │      1       │                          '14560'                           │     0      │      0.21      │  518.65  │    355.16    │   602.35    │
2020-11-19T09:58:54.0328151Z │    1    │  'other'  │      13      │ '25244, 23976, 18084, 29176, 26884, 9352 ... 7 more items' │   56.46    │      0.99      │  308.39  │    93.38     │   308.39    │
2020-11-19T09:58:54.0523328Z │    2    │ 'cypress' │      1       │                          '13848'                           │    1.82    │      0.46      │  150.64  │    152.74    │   165.25    │
2020-11-19T09:58:54.0523991Z │    3    │  'TOTAL'  │      15      │                            '-'                             │   58.28    │      5.84      │  977.68  │   1091.69    │   1338.12   │
2020-11-19T09:58:54.0524612Z └─────────┴───────────┴──────────────┴────────────────────────────────────────────────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘
2020-11-19T09:59:00.8160677Z 2020-11-19T09:59:00.815Z cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 61289 }
2020-11-19T09:59:04.7564405Z 2020-11-19T09:59:04.746Z cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 61389 }
2020-11-19T09:59:05.3816034Z 2020-11-19T09:59:05.381Z cypress:server:util:socket_allowed allowed socket closed, removing { localPort: 61403 }
2020-11-19T09:59:06.0742786Z 2020-11-19T09:59:06.071Z cypress:server:util:process_profiler current & mean memory and CPU usage by process group:
2020-11-19T09:59:06.0792205Z ┌─────────┬───────────┬──────────────┬────────────────────────────────────────────────────────────┬────────────┬────────────────┬──────────┬──────────────┬─────────────┐
2020-11-19T09:59:06.0806672Z │ (index) │   group   │ processCount │                            pids                            │ cpuPercent │ meanCpuPercent │ memRssMb │ meanMemRssMb │ maxMemRssMb │
2020-11-19T09:59:06.0901859Z ├─────────┼───────────┼──────────────┼────────────────────────────────────────────────────────────┼────────────┼────────────────┼──────────┼──────────────┼─────────────┤
2020-11-19T09:59:06.0930358Z │    0    │ 'plugin'  │      1       │                          '14560'                           │     0      │      0.21      │  518.68  │    356.61    │   602.35    │
2020-11-19T09:59:06.0948297Z │    1    │  'other'  │      12      │ '25244, 23976, 18084, 29176, 26884, 9352 ... 6 more items' │   13.98    │      1.11      │  306.16  │    95.24     │   308.39    │
2020-11-19T09:59:06.1145862Z │    2    │ 'cypress' │      1       │                          '13848'                           │    0.43    │      0.46      │  149.04  │    152.7     │   165.25    │
2020-11-19T09:59:06.1147184Z │    3    │  'TOTAL'  │      14      │                            '-'                             │   14.41    │      5.91      │  973.88  │   1090.66    │   1338.12   │
2020-11-19T09:59:06.1167857Z └─────────┴───────────┴──────────────┴────────────────────────────────────────────────────────────┴────────────┴────────────────┴──────────┴──────────────┴─────────────┘
2020-11-19T09:59:12.7409493Z 2020-11-19T09:59:12.736Z cypress:server:cypress exiting with err [OperationalError: EPERM: operation not permitted, unlink 'C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\browsers\chrome-stable\run-13848\CypressCache\Default\Cache\data_2'
2020-11-19T09:59:12.7480918Z 
2020-11-19T09:59:12.7930402Z ] {
2020-11-19T09:59:12.9137124Z   cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\browsers\chrome-stable\run-13848\CypressCache\Default\Cache\data_2'
2020-11-19T09:59:12.9907060Z   
2020-11-19T09:59:13.0034960Z   ] {
2020-11-19T09:59:13.0279710Z     errno: -4048,
2020-11-19T09:59:13.0360470Z     code: 'EPERM',
2020-11-19T09:59:13.0855857Z     syscall: 'unlink',
2020-11-19T09:59:13.1072126Z     path: 'C:\\Users\\agent-esw-01\\AppData\\Roaming\\Cypress\\cy\\production\\browsers\\chrome-stable\\run-13848\\CypressCache\\Default\\Cache\\data_2'
2020-11-19T09:59:13.1313669Z   },
2020-11-19T09:59:13.1449049Z   isOperational: true,
2020-11-19T09:59:13.1455752Z   errno: -4048,
2020-11-19T09:59:13.1464100Z   code: 'EPERM',
2020-11-19T09:59:13.1477831Z   syscall: 'unlink',
2020-11-19T09:59:13.1482595Z   path: 'C:\\Users\\agent-esw-01\\AppData\\Roaming\\Cypress\\cy\\production\\browsers\\chrome-stable\\run-13848\\CypressCache\\Default\\Cache\\data_2'
2020-11-19T09:59:13.1502142Z }
2020-11-19T09:59:13.1562893Z EPERM: operation not permitted, unlink 'C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\browsers\chrome-stable\run-13848\CypressCache\Default\Cache\data_2'
2020-11-19T09:59:13.1563663Z Error: EPERM: operation not permitted, unlink 'C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\browsers\chrome-stable\run-13848\CypressCache\Default\Cache\data_2'
2020-11-19T09:59:13.1566986Z 
2020-11-19T09:59:13.1568810Z 
2020-11-19T09:59:13.1569374Z 2020-11-19T09:59:12.764Z cypress:server:file get values from C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\cache
2020-11-19T09:59:13.1570063Z 2020-11-19T09:59:12.765Z cypress:server:file attempt to get lock on C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\cache
2020-11-19T09:59:13.1570968Z 2020-11-19T09:59:12.768Z cypress:server:file getting lock succeeded or failed for C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\cache
2020-11-19T09:59:13.1572205Z 2020-11-19T09:59:12.768Z cypress:server:file read C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\cache
2020-11-19T09:59:13.1572833Z 2020-11-19T09:59:12.769Z cypress:server:file read succeeded or failed for C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\cache
2020-11-19T09:59:13.1573223Z 2020-11-19T09:59:12.769Z cypress:server:file attempt to unlock C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\cache
2020-11-19T09:59:13.1574440Z 2020-11-19T09:59:12.770Z cypress:server:file unlock succeeded or failed for C:\Users\agent-esw-01\AppData\Roaming\Cypress\cy\production\cache
2020-11-19T09:59:13.1577827Z 2020-11-19T09:59:12.771Z cypress:server:api request to url: POST https://api.cypress.io/exceptions with params: {"body":{"err":{"name":"Error","message":"EPERM: operation not permitted, unlink <stripped-path>data_2'","stack":"Error: EPERM: operation not permitted, unlink <stripped-path>data_2'\n\n"},"version":"5.6.0","osName":"win32","osVersion":"10.0.18363","osCpus":[{"model":"Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz","speed":3600,"times":{"user":115385015,"nice":0,"sys":170788656,"idle":1014901781,"irq":635171}},{"model":"Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz","speed":3600,"times":{"user":389854468,"nice":0,"sys":821250875,"idle":89970109,"irq":155531}},{"model":"Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz","speed":3600,"times":{"user":220189890,"nice":0,"sys":390782078,"idle":690103484,"irq":225046}},{"model":"Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz","speed":3600,"times":{"user":203989750,"nice":0,"sys":313021421,"idle":784064281,"irq":235625}},{"model":"Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz","speed":3600,"times":{"user":177495046,"nice":0,"sys":305248765,"idle":818331640,"irq":275562}},{"model":"Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz","speed":3600,"times":{"user":165509984,"nice":0,"sys":164163109,"idle":971402359,"irq":265859}},{"model":"Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz","speed":3600,"times":{"user":156038000,"nice":0,"sys":103167625,"idle":1041869828,"irq":235125}},{"model":"Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz","speed":3600,"times":{"user":152720656,"nice":0,"sys":95664937,"idle":1052689859,"irq":220031}}],"osMemory":{"free":35828113408,"total":68573581312}},"headers":{"x-os-name":"win32","x-cypress-version":"5.6.0"}} and token: undefined
2020-11-19T09:59:13.1580785Z 2020-11-19T09:59:12.773Z cypress:network:agent addRequest called { isHttps: true, href: 'https://api.cypress.io/exceptions' }
2020-11-19T09:59:13.1581470Z 2020-11-19T09:59:12.773Z cypress:network:agent got family { family: undefined, href: 'https://api.cypress.io/exceptions' }
2020-11-19T09:59:13.1581881Z 2020-11-19T09:59:12.773Z cypress:network:agent Creating proxied socket for https://api.cypress.io/exceptions through http://192.168.1.3:3128
2020-11-19T09:59:13.1583014Z 2020-11-19T09:59:12.774Z cypress:server:cypress calling exit 1
2020-11-19T09:59:13.1583273Z 2020-11-19T09:59:12.774Z cypress:server:cypress about to exit with code 1
2020-11-19T09:59:13.1584786Z 2020-11-19T09:59:12.775Z cypress:network:connect successfully connected { opts: { port: 3128, host: '192.168.1.3', useTls: false, getDelayMsForRetry: [Function] }, iteration: 0 }
2020-11-19T09:59:13.1704877Z 2020-11-19T09:59:13.169Z cypress:cli child event fired { event: 'exit', code: 1, signal: null }
2020-11-19T09:59:13.1708690Z 2020-11-19T09:59:13.169Z cypress:cli child event fired { event: 'close', code: 1, signal: null }
2020-11-19T09:59:13.3190073Z ##[error]Cmd.exe exited with code '1'.
majco333 commented 3 years ago

We have the same problem last 2-3 weeks (Chrome + run on Azure Devops Self-Hosted agents).

It happens at 50 percent...

Many connections to chrome and node.js are created...

Currently this is not applicable for CI :cry:

HighCPU

majco333 commented 3 years ago

It works!!! when I run the agent not as a windows service...

RunAgent

It works without problems only when I run the agent as logged windows user. When I run the agent e.g. from windows tasks scheduler it's not working...

@jennifer-shehane Any ideas as next?

pierpo commented 3 years ago

I've been struggling for 2 days with this issue. I am trying to make Cypress work on a Gitlab CI job, but it just keeps saying Timed out waiting for the browser to connect. Retrying..., no matter what I do. I tried many of the advice here (no baseUrl in the config, etc.).

Some interesting context:

Edit:

firedev commented 3 years ago

I have the same issue – only one or two tests work, then it hits the timeout when going to the next file:

  │ Duration:     3 seconds                                                                        
  │ Spec Ran:     authorization.spec.js                                                            

────────────────

  Running:  home.spec.js                                                                    (2 of 3)

...

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

The browser never connected. Something is wrong. The tests cannot run. Aborting...
fgiroud commented 3 years ago

Hi, we are experiencing this too You can check the logs of our public PRs if you need more examples

nielsboecker commented 3 years ago

I've had the same error messages and resolved the issue by going headed as per https://github.com/cypress-io/cypress/issues/8606#issuecomment-703544094.

Ahm3d-A commented 3 years ago

I am facing same error the tests just stop and i get the same error:

Timed out waiting for the browser to connect. Retrying... Warning: Cypress failed to connect to Chrome via stdio after 1 minute, 0 seconds. Falling back to TCP... Connecting to Chrome via TCP was successful, continuing with tests.

Although it says reconnected again it just terminates the jenkins build and aborts.

Robert-Boily-Neuranet commented 3 years ago

I'm also experiencing this issue, but the affected cases are a bit narrower.

Minimum necessary test code:

/// <reference types="Cypress" />

describe('Connect to browser', function() {
  const TESTS = [...Array(100).keys()];

  TESTS.forEach(function (integer) {
    it(`attempt ${integer}`, function () {
      cy.wait(1000);
      expect(true).to.equal(true);
    })
  })
}) 

Issue occurs in Cypress v6.3.0 (via cypress run), with Chrome v88 and Edge v88, run headless. We are not running in CI - these are run locally (MacOS v10.13.6).

Terminal output when the issue occurs:

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

Roberts-MBP:cypress_tests robert$ npm run edge-spec

> cypress_tests@1.0.0 edge-spec /Users/robert/neuranet/page-builder/cypress_tests
> cypress run --env configFile=cypress.beta.json --spec 'integration/minimum.spec.js' --browser chrome --headless

Couldn't find tsconfig.json. tsconfig-paths will be skipped

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

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:    6.3.0                                                                              │
  │ Browser:    Chrome 88 (headless)                                                               │
  │ Specs:      1 found (minimum.spec.js)                                                          │
  │ Searched:   integration/minimum.spec.js                                                        │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  minimum.spec.js                                                                 (1 of 1)

Timed out waiting for the browser to connect. Retrying...
Warning: Cypress failed to connect to Chrome via stdio after 1 minute, 0 seconds. Falling back to TCP...
Connecting to Chrome via TCP was successful, continuing with tests.

  Connect to browser
    ✓ attempt 0 (1089ms)
    ✓ attempt 1 (1046ms)
    ✓ attempt 2 (1051ms)
    ✓ attempt 3 (1037ms)
    ✓ attempt 4 (1058ms)
    ✓ attempt 5 (1029ms)
    ✓ attempt 6 (1040ms)
    ✓ attempt 7 (1043ms)
    ✓ attempt 8 (1079ms)
    ✓ attempt 9 (1061ms)
    ✓ attempt 10 (1037ms)
    ✓ attempt 11 (1036ms)
    ✓ attempt 12 (1034ms)
    ✓ attempt 13 (1051ms)
    ✓ attempt 14 (1033ms)
    ✓ attempt 15 (1064ms)
    ✓ attempt 16 (1036ms)
    ✓ attempt 17 (1033ms)
    ✓ attempt 18 (1048ms)
    ✓ attempt 19 (1032ms)
    ✓ attempt 20 (1064ms)
    ✓ attempt 21 (1020ms)
    ✓ attempt 22 (1030ms)
    ✓ attempt 23 (1032ms)
    ✓ attempt 24 (1044ms)
    ✓ attempt 25 (1035ms)
    ✓ attempt 26 (1030ms)
    ✓ attempt 27 (1014ms)
    ✓ attempt 28 (1031ms)
    ✓ attempt 29 (1029ms)
    ✓ attempt 30 (1028ms)
    ✓ attempt 31 (1013ms)
    ✓ attempt 32 (1031ms)
    ✓ attempt 33 (1028ms)
    ✓ attempt 34 (1013ms)
    ✓ attempt 35 (1015ms)
    ✓ attempt 36 (1033ms)
    ✓ attempt 37 (1033ms)
    ✓ attempt 38 (1014ms)
    ✓ attempt 39 (1034ms)
    ✓ attempt 40 (1030ms)
    ✓ attempt 41 (1041ms)
    ✓ attempt 42 (1034ms)
    ✓ attempt 43 (1031ms)
    ✓ attempt 44 (1081ms)
    ✓ attempt 45 (1040ms)
    ✓ attempt 46 (1044ms)
    ✓ attempt 47 (1035ms)
    ✓ attempt 48 (1040ms)
    ✓ attempt 49 (1028ms)
    ✓ attempt 50 (1015ms)
    ✓ attempt 51 (1017ms)

Warning: Cypress failed to connect to Chrome via stdio after 1 minute, 0 seconds. Falling back to TCP...
Timed out waiting for the browser to connect. Retrying again...
Connecting to Chrome via TCP was successful, continuing with tests.

  Connect to browser
    ✓ attempt 0 (1057ms)
    ✓ attempt 1 (1054ms)
    ✓ attempt 2 (1043ms)
    ✓ attempt 3 (1110ms)
    ✓ attempt 4 (1049ms)
    ✓ attempt 5 (1041ms)
    ✓ attempt 6 (1110ms)
    ✓ attempt 7 (1105ms)
    ✓ attempt 8 (1014ms)
    ✓ attempt 9 (1017ms)
    ✓ attempt 10 (1032ms)
    ✓ attempt 11 (1032ms)
    ✓ attempt 12 (1014ms)
    ✓ attempt 13 (1029ms)
    ✓ attempt 14 (1029ms)
    ✓ attempt 15 (1037ms)
    ✓ attempt 16 (1043ms)
    ✓ attempt 17 (1042ms)
    ✓ attempt 18 (1032ms)
    ✓ attempt 19 (1034ms)
    ✓ attempt 20 (1054ms)
    ✓ attempt 21 (1044ms)
    ✓ attempt 22 (1117ms)
    ✓ attempt 23 (1033ms)
    ✓ attempt 24 (1033ms)
    ✓ attempt 25 (1035ms)
    ✓ attempt 26 (1030ms)
    ✓ attempt 27 (1033ms)
    ✓ attempt 28 (1044ms)
    ✓ attempt 29 (1039ms)
    ✓ attempt 30 (1027ms)
    ✓ attempt 31 (1013ms)
    ✓ attempt 32 (1038ms)
    ✓ attempt 33 (1030ms)
    ✓ attempt 34 (1030ms)
    ✓ attempt 35 (1033ms)
    ✓ attempt 36 (1035ms)
    ✓ attempt 37 (1042ms)
    ✓ attempt 38 (1014ms)
    ✓ attempt 39 (1028ms)
    ✓ attempt 40 (1015ms)
    ✓ attempt 41 (1015ms)
    ✓ attempt 42 (1031ms)
    ✓ attempt 43 (1032ms)
    ✓ attempt 44 (1034ms)
    ✓ attempt 45 (1014ms)
    ✓ attempt 46 (1016ms)
    ✓ attempt 47 (1032ms)
    ✓ attempt 48 (1031ms)
    ✓ attempt 49 (1033ms)
    ✓ attempt 50 (1027ms)
    ✓ attempt 51 (1014ms)
    ✓ attempt 52 (1015ms)
    ✓ attempt 53 (1029ms)
    ✓ attempt 54 (1012ms)

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

The browser never connected. Something is wrong. The tests cannot run. Aborting...
Warning: Cypress failed to connect to Chrome via stdio after 1 minute, 0 seconds. Falling back to TCP...
Connecting to Chrome via TCP was successful, continuing with tests.

  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        0                                                                                │
  │ Passing:      0                                                                                │
  │ Failing:      1                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  0                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     minimum.spec.js                                                                  │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

  (Video)

  -  Started processing:  Compressing to 32 CRF                                                     
    Compression progress:  55%
  -  Finished processing: /Users/robert/neuranet/page-builder/cypress_tests/cypress/v   (18 seconds)
                          ideos/minimum.spec.js.mp4                                                 

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

  (Run Finished)

       Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✖  minimum.spec.js                            0ms        -        -        1        -        - │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✖  1 of 1 failed (100%)                       0ms        -        -        1        -        -  

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cypress_tests@1.0.0 edge-spec: `cypress run --env configFile=cypress.beta.json --spec 'integration/minimum.spec.js' --browser chrome --headless`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the cypress_tests@1.0.0 edge-spec script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/robert/.npm/_logs/2021-02-01T16_39_49_599Z-debug.log
Roberts-MBP:cypress_tests robert$ 

Issue does not occur in:

troncoso commented 3 years ago

I'm also seeing the originally posted problem using:

Cypress 6.7.1 Chrome 89 or Election 87

The first spec always works, and any after fail due to "Timed out waiting for the browser to connect.".

I even copied my first spec to create a second one and it still fails. Unlike some other people in this thread, this is always happening to me lately. The spec I'm testing with is dirt simple:

describe('Home Page', () => {
    it('Shows correct text', () => {
        cy.visit('/');
        cy.contains('h1', 'Welcome Back!');
    });
});

I ran with debug logging on and I found this error after the first test completes:

  cypress:server:browsers killing browser process +3s
  cypress:server:run all BrowserWindows closed, not exiting +0ms
  cypress:server:browsers:electron closed event fired +1s
  cypress:server:windows error removing all extensions { err: TypeError: Object has been destroyed at Object.removeAllExtensions (/Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:51:26) at BrowserWindow.<anonymous> (/Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:398:19)     at Object.onceWrapper (events.js:422:26)     at BrowserWindow.emit (events.js:327:22) at tryToCall (/Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:28:27) at EventEmitter.kill (/Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/electron.js:409:20) at /Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/index.js:34:14 at Promise.cancellationExecute [as _execute] (/Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/debuggability.js:406:9) at Promise._resolveFromExecutor (/Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:518:18) at new Promise (/Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:103:10) at Object.kill [as close] (/Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/index.js:21:10) at Object.closeBrowser (/Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/lib/open_project.js:282:23) at /Users/spiderdev/Library/Caches/Cypress/6.7.1/Cypress.app/Contents/Resources/app/packages/server/lib/modes/run.js:1237:27 , extensions: undefined } +0ms
  cypress:server:preprocessor removeFile /Users/spiderdev/projects/anathletics/anathletics-app/test/e2e/integration/BaseTest.spec.ts +3s
  cypress:server:preprocessor base emitter plugin close event +0ms
  cypress:server:preprocessor base emitter native close event +0ms
  cypress:server:preprocessor base emitter native close event +0ms
  cypress:server:browsers browser process killed +1ms
  cypress:webpack close /Users/spiderdev/projects/anathletics/anathletics-app/test/e2e/integration/BaseTest.spec.ts +2s

That same error printed a second time somewhere in the middle of trying to run the second spec. I hope this helps.

wiuribecomodisimos commented 3 years ago

I resolve add: 127.0.0.1 localhost in /etc/hosts

majco333 commented 3 years ago

Cypress 7.3.0 it still doesn't work 😢 We have to use paid MS-hosted agents (limited possibility of parallelization, constantly downloading npm packages...)

lasithdilshan20 commented 3 years ago

Any update on this issue? I have an automated test suite. It consists of 30 specs that are executed one after the other on CI/CD. After the first spec is run, Cypress fails to open the browser or find it or something and the tests fail.

After the execution of 1st spec, this is happening to the rest of the specs. please provide a workaround? @jennifer-shehane

image

I tried with different browsers and follows the troubleshoot scenarios that cypress provides itself. but no luck

Versions Cypress 7.4 and 7.5 Chrome/ Electorn 91 VSTS for release automation