Skip to content
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

Error: could not find CRI target (Cypress 4.6.0) #7450

Closed
stevejefferies opened this issue May 22, 2020 · 32 comments · Fixed by #14348
Closed

Error: could not find CRI target (Cypress 4.6.0) #7450

stevejefferies opened this issue May 22, 2020 · 32 comments · Fixed by #14348

Comments

@stevejefferies
Copy link

Current behavior:

cypress run fails with the following error on Chrome:

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

The CDP port requested was 26359.

Error details:

Error: could not find CRI target
    at lazyAssLogic (C:\Users\user\AppData\Local\Cypress\Cache\4.6.0\Cypress\resources\app\packages\server\node_modules\lazy-ass\index.js:110:14)
    at Object.lazyAss (C:\Users\user\AppData\Local\Cypress\Cache\4.6.0\Cypress\resources\app\packages\server\node_modules\lazy-ass\index.js:115:28)
    at findStartPage (C:\Users\user\AppData\Local\Cypress\Cache\4.6.0\Cypress\resources\app\packages\server\lib\browsers\protocol.js:56:23)

Full log is also attached.

Note that this doesn't appear to be 100% consistent. With the below example I am seeing this maybe 25% of the time.

We had previously observed this before, and upgraded to both 3.8.3 as a result of: #6053

Then more recently, upgraded to 4.6.0 as a result of: #6518

Still observing on 4.6.0 as below though

Desired behavior:

Execution should not fail in this manner.

Test code to reproduce

  1. Clone https://github.com/stevejefferies/cypress-test-tiny
  2. Run cypress:run as defined in package.json e.g. npm run cypress:run

Versions

Cypress: 4.6.0
Browser: Chrome 83
OS: Windows 10

Debug Log

debug_log.txt

@jennifer-shehane
Copy link
Member

jennifer-shehane commented May 22, 2020

Oh, this is sad, we thought the increased timeout would help. Where are you running these tests when this typically happens? Locally? In a CI?

Running Chrome 83 headless

This happens at the very beginning of running the next spec (after the first spec has finished running), which is identical to #6518 We'll likely reopen that issue if others verify the fix did not work for them.

@stevejefferies
Copy link
Author

Unfortunately both observed locally and in a CI environment

@stevejefferies
Copy link
Author

For reference its more typically observed on running the second (or subsequent) specs. But has been observed on running the first spec on occasion.

@jareqpl
Copy link

jareqpl commented May 22, 2020

I have observed the same thing today. This started to occur after chrome update from 81 to 83.

@SonaliQA
Copy link

SonaliQA commented May 22, 2020

I also found the same error as @stevejefferies found
It working on cypress open UI but not able to run on the headless browser and not in CI environment also

@yetimaan
Copy link

yetimaan commented May 26, 2020

We are also seeing this issue in CI. Chrome Version 83.0.4103.61 headless with Cypress 3.8.3 in Azure Devops Windows CMD agent. We also got same error with latest Cypress 4.6.0. In the meantime, we're using Electron 78 in CI - which is working. I do not have this issue locally on MacOSX Chrome Version 83.0.4103.61.

@mikirobles
Copy link

mikirobles commented May 26, 2020

This is happening in my github actions flow in a very inconsistent basis. Tried with the latest cypress version and also 3.8.3.

Workflow:

name: PR - Testing

on: [pull_request]

jobs:
  cypress-run:
    name: Cypress
    runs-on: ubuntu-16.04
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      - uses: bahmutov/npm-install@v1
        with:
          useLockFile: false
      - name: Run tests
        uses: cypress-io/github-action@v1
        with:
          install: false
          browser: chrome
          start: npm run start-http
          wait-on: 'http://localhost:3000'
          config: baseUrl=http://localhost:3000,defaultCommandTimeout=10000

package.json:

    "cypress": "3.8.3", // Also happens with 4.5.0

Also note it's running with Chrome 81

@flotwig
Copy link
Contributor

flotwig commented May 26, 2020

If it's happening with Chrome 83, this could be the cause: #7433

@Sumanth1703
Copy link

I also found the same error as @stevejefferies found

I am facing this issue for both chrome and edge browser, It's working on cypress open UI but not able to run on the headless browser and not in CI environment also.

Any update on this issue ?

@PetMou
Copy link

PetMou commented May 29, 2020

Since chrome 83 was installed we also have this issue.

2020-05-29T10:15:14.1447528Z Failed to connect to Chrome, retrying in 1 second (attempt 60/62)
2020-05-29T10:15:14.1447578Z Failed to connect to Chrome, retrying in 1 second (attempt 61/62)
2020-05-29T10:15:14.1447611Z Failed to connect to Chrome, retrying in 1 second (attempt 62/62)
2020-05-29T10:15:14.1447646Z Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 50 seconds.
2020-05-29T10:15:14.1447669Z 
2020-05-29T10:15:14.1447719Z This usually indicates there was a problem opening the Chrome browser.
2020-05-29T10:15:14.1447827Z 
2020-05-29T10:15:14.1447858Z The CDP port requested was 52137.
2020-05-29T10:15:14.1447878Z 
2020-05-29T10:15:14.1447906Z Error details:
2020-05-29T10:15:14.1447941Z 
2020-05-29T10:15:14.1447970Z Error: could not find CRI target
2020-05-29T10:15:14.1448012Z     at lazyAssLogic (C:\Users\ZMSAAZU002\AppData\Local\Cypress\Cache\4.7.0\Cypress\resources\app\packages\server\node_modules\lazy-ass\index.js:110:14)
2020-05-29T10:15:14.1448064Z     at Object.lazyAss (C:\Users\ZMSAAZU002\AppData\Local\Cypress\Cache\4.7.0\Cypress\resources\app\packages\server\node_modules\lazy-ass\index.js:115:28)
2020-05-29T10:15:14.1448121Z     at findStartPage (C:\Users\ZMSAAZU002\AppData\Local\Cypress\Cache\4.7.0\Cypress\resources\app\packages\server\lib\browsers\protocol.js:56:23)

@thdepauw
Copy link

thdepauw commented Jun 3, 2020

Any update on this issue?

We are also facing this issue on our local machines (win 10 - chrome 83.0.4103.61) when running headless.
Our CI on Azure DevOps hasn't encountered this issue yet since it is still running on chrome 81.

The workaround of @Diald to run on elektron is not an option for us.

@electrofLy
Copy link

electrofLy commented Jun 3, 2020

Experiencing this issue with Cypress 4.5.0 and HeadlessChrome 83.0.4103 (Windows 8.1.0.0).

@BPCypress
Copy link

Experiencing this issue with Cypress 4.5.0 and headless Chrome 83.0.4103.61 (Windows 10)

@rafaelrene
Copy link

Experiencing this as well. Cypress 4.7.0 & headless chrome 83.0.4103.61 (Windows 10)

@stevejefferies
Copy link
Author

stevejefferies commented Jun 5, 2020

Did some digging on this. This looks to be a Chrome issue in that the underlying issue observed (no targets returned from call to CDP.List in chrome remote interface) can be replicated outside of Cypress completely. e.g.:

const CDP = require('chrome-remote-interface');
const { spawn  } = require("child_process");

const port = 8004
const stable = "chrome.exe"
const chrome = spawn(stable, ['about:blank', 
'--headless', 
`--remote-debugging-port=${port}`, 
'--remote-debugging-address=127.0.0.1'
]);

(function retryLoop(i) {
    setTimeout(function() {
        CDP.List({port: port}, (err, targets) => {
            console.log(err)
            if (!err) {
                console.log(targets);
            }
        });              
      if (--i) retryLoop(i);
    }, 3000)
  })(10);

results in an empty list - as you see when this fails in Cypress.

Digging further, it appears to be down to the Chrome renderer child process crashing. There are numerous open tickets with the Chromium project which highlight this issue so its hard to determine the actual stability of this. But a few options I tried from the issues in the Chromium project do seem to have solved this from my limited local testing (Win 10 only):

  1. disable gpu when launching Chrome on windows by adding the --disable-gpu flag on browser launch, as Cypress already does for Chrome on linux
  2. specify a given GL to use, using --use-gl=desktop/swiftshader both seem to give stable results locally
  3. Chrome 84 (in beta, tested: 84.0.4147.38) seems to be stable to this issue as well
  4. (and slightly weirdly) not launching "about:blank" instead using a different page, also seems to be more stable, although I cannot see why this would be.

Is there a reason why Cypress only sets --disable-gpu for linux (here)? Happy to make this fix.

@Sumanth1703
Copy link

@stevejefferies i am facing the same issue with edge browser as well . Do you think it’s same problem with all chromium related browsers ?

@ghost
Copy link

ghost commented Jun 6, 2020

Following this thread as it's affecting all my chrome headless tests with Cypress 4.7.0.

@stevejefferies
Copy link
Author

stevejefferies commented Jun 8, 2020

Should have added to my comment above, for those looking for a potential workaround adding the disable-gpu flag on browser launch (plugins/index.js) seems stable for me at least locally:
Cypress 4+:

module.exports = (on, config) => {
  on('before:browser:launch', (browser, launchOptions) => {
    if (browser.name === 'chrome' && browser.isHeadless) {
      launchOptions.args.push('--disable-gpu');
      return launchOptions
    }
  });
}

Or before Cypress 4:

module.exports = (on, config) => {
  on('before:browser:launch', (browser, args) => {
    if (browser.name === 'chrome' && browser.isHeadless) {
      args.push(
        '--disable-gpu'
      );
      return args;
    }
  });
}

@kaiyoma
Copy link

kaiyoma commented Jun 12, 2020

Experiencing the same problem on my Windows 10 laptop with Chrome 83 (headless) and Cypress 4.7.0. We haven't been seeing this issue in our CI, which runs Chrome 83 (headless) on Linux.

The workaround mentioned above in #7450 (comment) (adding --disable-gpu) fixes the issue for me. Thanks @stevejefferies!

@jennifer-shehane
Copy link
Member

@stevejefferies Well, the original code/issue to add --disabled-gpu for linux is not very clear on the intent of why we added it for only linux: #1021

I'm not sure --disable-gpu should be necessary at all based on these comments https://bugs.chromium.org/p/chromium/issues/detail?id=737678 It mentions being required for Windows until a bug is fixed, but that bug was fixed.

It would be ideal if we could track down what Chromium bug this is.

@kaiyoma
Copy link

kaiyoma commented Jun 15, 2020

We just ran into this problem in our CI, which runs on Linux and specifies the --disable-gpu flag.

10:12:07  Failed to connect to Chrome, retrying in 1 second (attempt 18/62)
10:12:07  Failed to connect to Chrome, retrying in 1 second (attempt 19/62)
10:12:08  Failed to connect to Chrome, retrying in 1 second (attempt 20/62)
10:12:10  Failed to connect to Chrome, retrying in 1 second (attempt 21/62)
10:12:10  Failed to connect to Chrome, retrying in 1 second (attempt 22/62)
10:12:11  Failed to connect to Chrome, retrying in 1 second (attempt 23/62)
10:12:12  Failed to connect to Chrome, retrying in 1 second (attempt 24/62)
10:12:14  Failed to connect to Chrome, retrying in 1 second (attempt 25/62)
10:12:27
10:12:27         "before each" hook for "should load all the sections without any warnings or errors":
10:12:27       CypressError: Cypress command timeout of `4000ms` exceeded.

@wasiqkhan786
Copy link

wasiqkhan786 commented Aug 25, 2020

I have update cypress to 4.6.0 but still facing the issue. Everytime on different test.please solve it .

@nids2307
Copy link

nids2307 commented Aug 26, 2020

Any updates on this issue?

I have been seeing it intermittently over the last few weeks, using Chrome 83 and cypress 4.12.1

Failed to connect to Chrome, retrying in 1 second (attempt 53/62)

Failed to connect to Chrome, retrying in 1 second (attempt 54/62)

Failed to connect to Chrome, retrying in 1 second (attempt 55/62)

Failed to connect to Chrome, retrying in 1 second (attempt 56/62)

Failed to connect to Chrome, retrying in 1 second (attempt 57/62)

Failed to connect to Chrome, retrying in 1 second (attempt 58/62)

Failed to connect to Chrome, retrying in 1 second (attempt 59/62)

Failed to connect to Chrome, retrying in 1 second (attempt 60/62)

Failed to connect to Chrome, retrying in 1 second (attempt 61/62)

Failed to connect to Chrome, 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 Chrome browser.



The CDP port requested was 35608.



Error details:



Error: connect ECONNREFUSED 127.0.0.1:35608

    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14)



error Command failed with exit code 1.

@wasiqkhan786
Copy link

wasiqkhan786 commented Aug 27, 2020

@nids2307 try below code in Plugins/index.js its working

 module.exports = (on, config) => {
  on('before:browser:launch', (browser, launchOptions) => {
    if (browser.name === 'chrome' && browser.isHeadless) {
      launchOptions.args.push('--disable-gpu');
      return launchOptions
    }
  });
}

@nids2307
Copy link

Thank you Wasiq!

@nids2307
Copy link

nids2307 commented Sep 8, 2020

@wasiqkhan786 : I have been seeing the same error again despite of adding the code you advised me to add.

I am using Cypress 5.0.0 now.

@wasiqkhan786
Copy link

@nids2307 please try with cypress version 4.12.1

@nids2307
Copy link

Does anyone know if there is a workaround available for versions higher than 4.12.1. I have made quite a few changes when I upgraded the version to 5.0.0.

@elpaisa
Copy link

elpaisa commented Sep 21, 2020

I still have the issue Error: connect ECONNREFUSED 127.0.0.1:---- Cypress 4.9.0 Chrome 85 Mac OS Catalina, running with --disable-gpu, works with Electron

@DogaruRaluca
Copy link

DogaruRaluca commented Oct 13, 2020

Experiencing this as well. Cypress 4.12.1 & Chrome 86. I see that the version of Chrome is newly upgraded. Could that be the problem?

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 Chrome browser.
The CDP port requested was 55062.
Error details:
Error: connect ECONNREFUSED 127.0.0.1:55062 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14)

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 19, 2021

The code for this is done in cypress-io/cypress#14348, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 20, 2021

Released in 6.3.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.3.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jan 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.