cypress-har-generator
cypress-har-generator copied to clipboard
Error: Failed to connect to Chrome Debugging Protocol
Running the plugin out-of-the-box on macOS, I get this error:
$ npx cypress run --config baseUrl=https://my.domain --browser chrome
From Node.js Internals:
Error: Failed to connect to Chrome Debugging Protocol
Common situations why this would fail:
- you forgot to run Chrome in headless mode
- you use Chrome version 58 or earlier
- you have weird RDP configuration settings
The stack trace for this error is:
at t.CRIConnection.<anonymous> (/Users/nfelger/Dropbox/dev/projects/myproj/test/load/node_modules/@neuralegion/cypress-har-generator/dist/webpack:/@neuralegion/cypress-har-generator/src/cdp/CRIConnection.ts:37:27)
at Generator.next (<anonymous>)
at fulfilled (/Users/nfelger/Dropbox/dev/projects/myproj/test/load/node_modules/tslib/tslib.js:115:62)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Versions:
Cypress: 9.6.1
Browser: Chrome 101 (headless)
Node Version: v17.8.0 (/usr/local/Cellar/node/17.8.0/bin/node)
macOS: 12.2.1
@neuralegion/cypress-har-generator: 5.3.0
My Cypress test:
describe("static pages", () => {
before(() => {
// start recording
cy.recordHar();
});
after(() => {
cy.saveHar();
});
it("Home page", () => {
cy.visit("/");
});
});
Poking around in logs and code a bit, it seems like Chrome is started with --remote-debugging-address=127.0.0.1
but cypress-har-generator tries to access it on ::1
, which Chrome isn't listening on.
I can fix this for me by changing https://github.com/NeuraLegion/cypress-har-generator/blob/1188c09df99958f77d35c79d7fe1717bb5c9fbdd/src/Plugin.ts#L54 to:
{ host: "127.0.0.1", port: this.rdpPort },
But I'm not sure if that's the right way to go about it?
I have the same issue on Arch Linux, unfortunately I was not able to fix it like you, but when I added debugging address as a launch option like:
on("before:browser:launch", (browser = {}, launchOptions) => {
ensureBrowserFlags(browser, launchOptions);
launchOptions.args.push("--remote-debugging-address=::1");
return launchOptions;
});
};
The error changed to:
Still waiting to connect to Chromium, retrying in 1 second (attempt 18/62)
...
Still waiting to connect to Chromium, 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 Chromium browser.
The CDP port requested was 33847.
Error: connect ECONNREFUSED 127.0.0.1:33847
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
Having this same issue and I can't even figure out how to alter it. Does this plugin not work when running tests against localhost
?
I encountered the same problem. But only after installing a new Node version. It works fine in 16.17.0, but in 18.7.0 the problem started to happen for me. So for now I'm back to 16.17.0
I encountered the same problem. But only after installing a new Node version. It works fine in 16.17.0, but in 18.7.0 the problem started to happen for me. So for now I'm back to 16.17.0
Downgrading node solved the issue, thanks!
Hi @nfelger, Thanks for the report. unfortunately, I'm not able to reproduce the same behavior using Node.js 14, 16, or 18 on macOS. Anyway, I'm going to specify a host according to arguments passed by Cypress. Let's check if it works for you.