Opening 2 instances of Cypress App fails with connection error to Chrome DevTools Protocol
See original GitHub issueCurrent behavior:
The tests commands/navigation_spec.coffee
and e2e/redirects_specs.coffee
fail on Chrome 78 but pass on Electron.
The CLI outputs the following when one of these tests is run:
Failed to connect to Chrome, retrying in 1 second (attempt 18/32)
Failed to connect to Chrome, retrying in 1 second (attempt 19/32)
Failed to connect to Chrome, retrying in 1 second (attempt 20/32)
Failed to connect to Chrome, retrying in 1 second (attempt 21/32)
Failed to connect to Chrome, retrying in 1 second (attempt 22/32)
Failed to connect to Chrome, retrying in 1 second (attempt 23/32)
Failed to connect to Chrome, retrying in 1 second (attempt 24/32)
Failed to connect to Chrome, retrying in 1 second (attempt 25/32)
Failed to connect to Chrome, retrying in 1 second (attempt 26/32)
Failed to connect to Chrome, retrying in 1 second (attempt 27/32)
Failed to connect to Chrome, retrying in 1 second (attempt 28/32)
Failed to connect to Chrome, retrying in 1 second (attempt 29/32)
Failed to connect to Chrome, retrying in 1 second (attempt 30/32)
Failed to connect to Chrome, retrying in 1 second (attempt 31/32)
Failed to connect to Chrome, retrying in 1 second (attempt 32/32)
Here’s the error from Cypress:
Here’s what CircleCI do (when I had Chrome 78 to run the tests): https://app.circleci.com/jobs/github/cypress-io/cypress/184452
Desired behavior:
These tests should pass on both Chrome 78 and Electron. These tests used to pass. (They must pass on Chrome 73 because Chrome 73 was used in the CircleCI tests.)
Steps to reproduce: (app code and test code)
- Open two terminals.
- On both terminals:
cd packages/driver
. - On the first terminal:
npm start
- On the second terminal:
npm run cypress:open
- From the Cypress window, search for one of the failing tests (navigation or redirect).
- Ensure Chrome (not Electron) is selected from Cypress.
- Click “Run”.
Versions
Cypress 3.6.0 Chrome 78.0.3904.87 MacOS 10.15 Catalina
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Cypress Failed to Connect to Chrome: 5 Ways to Easily Fix it
2. Use Chrome-flavored browsers · Open Cypress by typing this command in the terminal: node_modules/. · Run the following command in the terminal: ......
Read more >Error Messages | Cypress Documentation
Getting this error means you've tried to interact with a "dead" DOM element - meaning the current subject has been removed from the...
Read more >cypress-io/cypress - Gitter
Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 20 seconds. This usually indicates there was a problem...
Read more >Cypress tests against devtools port only - Stack Overflow
It is not possible. Testing with Cypress a web page in embedded Chromium running in your application means Cypress needs to connect to ......
Read more >Cypress Automation - Gleb Bahmutov
Using Chrome Debugger Protocol from Cypress. When Cypress controls a Chromium browser, it has an open remote interface connection between ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a known issue - if you have 2 instances of Cypress Open, this can happen - although there is something particular about the situation that does not occur on all of our teammates machines that we haven’t been able to narrow down.
From
I can recreate this behavior by doing the following:
cypress open
in one terminal from a project.cypress open
in another terminal from another project.My DEBUG logs
Specific logs at time of error toward the end:
@clarmso The issue you talk about in the OP happens, I believe, because Cypress shares a
user-data-dir
between Chrome processes.So Chrome #1 launches with
chrome --user-data-dir=~/.config/Cypress/cy/production/browsers/chrome/interactive --remote-debugging-port=12345
And Chrome #2 launches with
chrome --user-data-dir=~/.config/Cypress/cy/production/browsers/chrome/interactive --remote-debugging-port=45678
And because the data dir is the same, Chrome collates the second launch into the first process, and drops the
--remote-debugging-port
in the process. This leads to the CDP error you’re getting.I see 2 ways to fix this:
user-data-dir
s for each project, hashed by the project pathI like the first option best, because it totally cleans up this experience while still allowing users to install extensions inside Chrome for debugging. Plus, currently, it’s a miracle if you can actually get 2 Cypress instances running at once, because they’ll fight over the Chrome instance. This would fix that.