cypress-io / cypress

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

Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 50 seconds. #27830

Open StefanoBalzarottiNozomi opened 1 year ago

StefanoBalzarottiNozomi commented 1 year ago

Current behavior

Randomly on a very slow windows machine I get this error:

Still waiting to connect to Edge, retrying in 1 second (attempt 62/62)
Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 50 seconds.

This usually indicates there was a problem opening the Edge browser.

The CDP port requested was 50325.

Error: connect ECONNREFUSED 127.0.0.1:50325
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)

Desired behavior

Cypress is able to connect to Chrome DevTools Protocol in X seconds. Please give a way to increase the timeout, or fix the issue that makes the connection fail.

Test code to reproduce

The problem is machine dependent, not code dependent, it can fail with any test.

Cypress Version

13.1.0

Node version

18.4.0

Operating System

Windows 10

Debug Logs

No response

Other

No response

nagash77 commented 1 year ago

Hi @StefanoBalzarottiNozomi browser and what version of that browser are you using when you encounter this issue?

StefanoBalzarottiNozomi commented 1 year ago

Hi @StefanoBalzarottiNozomi browser and what version of that browser are you using when you encounter this issue?

Microsoft Edge 116.

StefanoBalzarottiNozomi commented 1 year ago

Since maybe it's hard for you to reproduce and fix, and maybe can just be fixed by increasing the timeout. Can't you just expose the option to increase the timeout? Something like browserConnectionTimeout in cypress.config.ts.

IllyaKh commented 1 year ago

Have the same issue in the Github Actions pipeline + locally, everything worked fine two weeks ago.

russell-accurx commented 1 year ago

Seeing a similar thing happening, with slightly different logging, after upgrading Cypress to 13.2.0. About to upgrade to 13.3.0 to see if that fixes it but from the changelog I can't see anything that obviously would fix it.

This gets logged out after more than a minute of retrying:

Still waiting to connect to Edge, retrying in 1 second (attempt 52/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 53/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 54/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 55/62)

Timed out waiting for the browser to connect. Retrying...
There was an error reconnecting to the Chrome DevTools protocol. Please restart the browser.

Error: connect ECONNREFUSED 127.0.0.1:40407
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16)
jerkovicl commented 1 year ago

For me it was working on Cypress 13.2.0, but its not working on 13.3.0. Using docker image with tag (cypress-13.3.0-node-20.6.1-chrome-116.0.5845.187-1-ff-117.0-edge-116.0.1938.76-1) and gitlab pipeline

MikeMcC399 commented 1 year ago
microsoft-edge --version
Microsoft Edge 118.0.2088.61 

Microsoft Edge is slow to start up. Locally on Ubuntu 22.04 and on GitHub runner ubuntu-22.04 it regularly shows

Still waiting to connect to Edge, retrying in 1 second

and this is observable in workflow logs on https://github.com/cypress-io/github-action/actions/workflows/example-edge.yml, for example https://github.com/cypress-io/github-action/actions/runs/6589879261/job/17905293268

If Edge is used again in the same session, then startup is quicker and no wait messages are logged.

For test purposes I ran Edge with puppeteer on Ubuntu before running Cypress and in that case there were no wait messages output by Cypress.

Also if Cypress is run a second time in the same session, then the second Cypress test of Edge runs with no waiting messages.

Suggestion

Either:

  1. Increase the timeout for Edge
  2. Provide a timeout parameter for browser wait

Also Microsoft could be encouraged to improve Edge such that it starts up faster in headless mode for testing purposes. Microsoft Edge should have similar start-up performance to Google Chrome and Chromium.

MikeMcC399 commented 1 year ago

@jennifer-shehane Will you re-assign this?

MikeMcC399 commented 1 year ago

This issue has started occasionally occurring in the workflow

example-edge.yml in

cypress-io/github-action.

magarwal19 commented 11 months ago

I am facing same issue with Chrome 119 version also

AnkaNik commented 11 months ago

Start getting same problem . did not change anything

  1. Chrome
    • Name: chrome
    • Channel: stable
    • Version: 120.0.6099.129

Cypress Version: 12.17.3 (stable) System Platform: darwin (21.4.0)

cypress-app-bot commented 5 months ago

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.

cypress-app-bot commented 4 months ago

This issue has been closed due to inactivity.

StefanoBalzarottiNozomi commented 4 months ago

to update, I solved the issue by using a more powerful windows agent. Not sure if the issue still occurs with latest versions of cypress. I still think that give the possibility to configure the timeout would have been a useful feature.

MikeMcC399 commented 4 months ago

Regarding my https://github.com/cypress-io/cypress/issues/27830#issuecomment-1782843917

The last failure in https://github.com/cypress-io/github-action/actions/workflows/example-edge.yml was 9 months ago and the logs have been purged in the meantime so it's not possible to trace the reason. This workflow follows the latest release of Cypress closely and currently runs under Cypress 13.13.0. So in this example workflow Edge is no longer an issue.

Alecsou commented 4 months ago

I have currently this problem with Edge, on an Azure Devops pipeline with a windows-latest agent.

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress:        13.13.0                                                                        │
│ Browser:        Edge 126 (headless)                                                            │
│ Node Version:   v18.19.0 (C:\hostedtoolcache\windows\node\18.19.0\x64\node.exe)                │

...

Still waiting to connect to Edge, retrying in 1 second (attempt 62/62)
Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 50 seconds.

EDIT : Tried swapping the agent for a more powerful ubuntu-latest agent. I now have just a few Still waiting to connect to Edge, retrying in 1 second (attempt x/62) messages, but it fails randomly to load pages on certain tests with no pattern, even with increased pageLoadTimeout

MikeMcC399 commented 4 months ago

@Alecsou

It sounds like this issue needs to be re-opened. Is it possible for you to try with Node.js 20.x LTS?

Alecsou commented 4 months ago

So I'm currently trying with Node.js 20.x, and where it would always crash with 18.x, it doesn't do it anymore on a dozen runs up until here. I still get the Still waiting to connect to Edge, retrying in 1 second (attempt x/62) messages though.

But it feels really like walking on eggs, it could blow at any moment, as failing to open the browser fails the whole job and we have no explanation whatsoever on how and why this is happening.

MikeMcC399 commented 4 months ago

On GitHub Actions workflow https://github.com/MikeMcC399/github-action/actions/runs/9894339824/job/27331610912 I am seeing Cypress having a hard time connecting to Edge 126 on Ubuntu and Windows. In the end, it does succeed. macOS showed no issue, but that may be coincidence.

It seems that there is still an underlying open problem.

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        13.13.0                                                                        │
  │ Browser:        Edge 126 (headless)                                                            │
  │ Node Version:   v20.13.1 (/home/runner/runners/2.317.0/externals/node20/bin/node)              │
  │ Specs:          1 found (spec.cy.js)                                                           │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

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

  Running:  spec.cy.js                                                                      (1 of 1)
before launching browser
{
  name: 'edge',
  family: 'chromium',
  channel: 'stable',
  displayName: 'Edge',
  version: '126.0.2592.87',
  path: 'microsoft-edge',
  minSupportedVersion: 79,
  majorVersion: '126',
  isHeadless: true,
  isHeaded: false
}
Still waiting to connect to Edge, retrying in 1 second (attempt 18/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 19/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 20/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 21/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 22/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 23/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 24/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 25/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 26/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 27/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 28/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 29/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 30/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 31/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 32/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 33/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 34/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 35/62)

top window inner w, h is [123](https://github.com/MikeMcC399/github-action/actions/runs/9894339824/job/27331610912#step:3:124)2x645
  ✓ works (2501ms)

  1 passing (4s)
Alecsou commented 4 months ago

So after some more pipeline runs, it seems Node 20.x makes it more reliable but not perfectly, I've had a crash due to this problem once out of 8 runs. It really feels not normal not to have this kind of feature running without the fear of a crash happening.

MikeMcC399 commented 4 months ago

@Alecsou

Thanks for your feedback! If this issue is not re-opened it may make sense to open a new one with fresh information.

I can still reproduce the reluctance to connect to Edge 126 on Ubuntu and Windows using the latest Cypress version 13.13.1. This is again running under GitHub Actions.

MikeMcC399 commented 3 months ago

See multiple connection attempts with success on https://github.com/MikeMcC399/github-action/actions/runs/10322634026

Cypress 13.13.2, GitHub Actions

DevTools listening on ws://127.0.0.1:34033/devtools/browser/35134310-4268-4ba2-8531-59463d9c6c07

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

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        13.13.2                                                                        │
  │ Browser:        Edge 127 (headless)                                                            │
  │ Node Version:   v20.13.1 (/home/runner/runners/2.317.0/externals/node20/bin/node)              │
  │ Specs:          1 found (spec.cy.js)                                                           │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

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

  Running:  spec.cy.js                                                                      (1 of 1)
before launching browser
{
  name: 'edge',
  family: 'chromium',
  channel: 'stable',
  displayName: 'Edge',
  version: '127.0.2651.86',
  path: 'microsoft-edge',
  minSupportedVersion: 79,
  majorVersion: '127',
  isHeadless: true,
  isHeaded: false
}
Still waiting to connect to Edge, retrying in 1 second (attempt 18/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 19/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 20/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 21/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 22/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 23/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 24/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 25/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 26/62)
Still waiting to connect to Edge, retrying in 1 second (attempt 27/62)

top window inner w, h is [123](https://github.com/MikeMcC399/github-action/actions/runs/10322634026/job/28578270607#step:3:124)2x643
  ✓ works (2715ms)

  1 passing (5s)
Nmasmae commented 3 months ago

@MikeMcC399 how did it work for you? i currently have the same issue!

MikeMcC399 commented 3 months ago

@Nmasmae

how did it work for you? i currently have the same issue!

I didn't do anything special to make it work. You can see the workflow on https://github.com/MikeMcC399/github-action/blob/test/edge-all-os/.github/workflows/example-edge.yml

Unfortunately I don't have the skills to debug why it is taking a long time for Cypress to establish a connection to Edge. I also don't know why it doesn't appear to be a problem on the GitHub macos-13 runner, but only on Ubuntu and Windows.

Since the connection time is long and variable, for some situations it succeeds and in other environments it times out. I made some other observations last year in https://github.com/cypress-io/cypress/issues/27830#issuecomment-1774829043. There hasn't been any feedback on those points so far.