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

Unable to connect to the remote-debugging-port via Chome Dev Protocol (CDP) #14835

Closed
tomardern opened this issue Jan 30, 2021 · 6 comments
Closed
Labels
stale no activity on this issue for a long period

Comments

@tomardern
Copy link

tomardern commented Jan 30, 2021

Current behavior

I am trying to use Chrome Dev Protocol (CDP) to connect to the spawned Chrome Instance via $(npm bin)/cypress open. The overall aim, is to run the built in chrome V8 profiler to get the code coverage for all the files.

To find the port, I've added the following to plugins/index:

on("before:browser:launch", (browser, launchOptions) => {
    console.log(launchOptions.args);
});

Which returns the following:

...
  '--disable-web-security',
  '--allow-running-insecure-content',
  '--proxy-bypass-list=<-loopback>',
  '--remote-debugging-port=64739', <-- This changes each time
  '--remote-debugging-address=127.0.0.1',
  '--remote-debugging-pipe',
...

However, when I try and connect to the spawned CDP (either by opening http://127.0.0.1:64739) or even just running the Port Scan utility on Mac OSX Catalina, I'm unable to see CDP running, and unable to connect.

Interestingly, adding the following to my test script shows the console message, so I presume that Chrome Devtools Protocol is available, just not accessible outside of Cypress.

Cypress.automation("remote:debugger:protocol", {
  command: "Runtime.evaluate",
  params: {
    expression: "console.log('hello world 2');",
  },
});

Desired behavior

Able to connnect to Cypress's spawned Chrome instance via CDP.

Test code to reproduce

(Any basic cypress install, with the above changes in plugins/index

Versions

Cypress: 6.3.0
Node: (12.18.3)
Chrome: Version 88.0.4324.96 (Official Build) (x86_64)
Mac: MacOSX Catalina 10.15.1

@watanas
Copy link

watanas commented Feb 1, 2021

This workflow used to work in cypress@6.2.1. Perhaps the use of the --remote-debugging-pipe Chrome flag has changed, maybe related to #14348?

@leveneg
Copy link

leveneg commented Mar 17, 2021

I too am seeing this behavior on latest. Unable to connect with both chrome and firefox.

edit: nevermind it has something to do with my vpn settings still unsure what's going on.

@flotwig
Copy link
Contributor

flotwig commented Jun 7, 2021

This is strange, connecting to CDP like this should work.

@tomardern Are you waiting for the browser to launch in your and retrying the connection? before:browser:launch runs BEFORE the browser is opened, so the CDP port is not immediately usable at this point.

Is anyone having this issue not on Mac?

--

EDIT: also, I see you are trying to collect codecov info via CDP. Cool! If you're not aware, @bahmutov experimented with this a year ago, and got pretty close: https://github.com/bahmutov/cypress-native-chrome-code-coverage-example

@fstylermiller
Copy link

I am also seeing this issue. Running cypress@8.4.0
MacOS Big Sur 11.5.2

My chrome configuration:

name:"chrome"
family:"chromium"
channel:"stable"
displayName:"Chrome"
version:"93.0.4577.82"
path:"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
minSupportedVersion:64
majorVersion:93

Running
$ DEBUG=cypress:* ./node_modules/.bin/cypress open

I can see that Cypress attempts to start the chrome debugger with the following flags:

cypress:launcher spawning browser with args { args: [ ... '--remote-debugging-port=60030', '--remote-debugging-address=127.0.0.1', ... ] }

Immediately following is:

cypress:network:connect received error on connect, retrying { iteration: 0, delay: 100, err: Error: connect ECONNREFUSED 127.0.0.1:60030     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) { errno: -61, code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 60030 } }

Cypress then times out.

@sverkunov
Copy link

What I've found out, in hosts file, my localhost address 127.0.0.1 were available only under prefixed name (127.0.0.1 docker.internal) and was commented out for a default 127.0.0.1 localhost name. After changing it, works as expected 👍

@cypress-app-bot
Copy link
Collaborator

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 cypress-app-bot added the stale no activity on this issue for a long period label May 17, 2023
@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale no activity on this issue for a long period
Projects
None yet
Development

No branches or pull requests

7 participants