-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: do not override electron debug port if previously set #27169
Conversation
30 flaky tests on run #48517 ↗︎
Details:
commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-firefox
e2e/origin/commands/assertions.cy.ts • 1 flaky test • 5x-driver-firefox
cypress/cypress.cy.js • 3 flaky tests • 5x-driver-firefox
create-from-component.cy.ts • 1 flaky test • app-e2e
cypress-in-cypress.cy.ts • 1 flaky test • app-e2e
The first 5 flaky specs are shown, see all 17 specs in Cypress Cloud. This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
// if port was already set via passing from environment variable ELECTRON_EXTRA_LAUNCH_ARGS, | ||
// then just keep the supplied value | ||
if (app.commandLine.getSwitchValue('remote-debugging-port')) { | ||
return | ||
} | ||
|
||
const port = await getPort() | ||
|
||
// set up remote debugging port | ||
app.commandLine.appendSwitch('remote-debugging-port', String(port)) | ||
|
||
return app.commandLine.appendSwitch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// if port was already set via passing from environment variable ELECTRON_EXTRA_LAUNCH_ARGS, | |
// then just keep the supplied value | |
if (app.commandLine.getSwitchValue('remote-debugging-port')) { | |
return | |
} | |
const port = await getPort() | |
// set up remote debugging port | |
app.commandLine.appendSwitch('remote-debugging-port', String(port)) | |
return app.commandLine.appendSwitch | |
// if port was already set via passing from environment variable ELECTRON_EXTRA_LAUNCH_ARGS, | |
// then just keep the supplied value | |
if (!app.commandLine.getSwitchValue('remote-debugging-port')) { | |
const port = await getPort() | |
// set up remote debugging port | |
app.commandLine.appendSwitch('remote-debugging-port', String(port)) | |
} | |
return app.commandLine.appendSwitch |
Should we preserve the existing return value for either path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was the one that added the return value when trying to debug my unit test. It is not used so I just removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code seems fine. I followed the repro instructions but I did not encounter an error, though 🤔
Co-authored-by: Mike Plummer <mike-plummer@users.noreply.github.com>
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Additional details
PR #26573 added logic to assign a random available port for Electron to use as the debugging port to connect to CDP. This PR adds a check to make sure if a port has been passed in via setting an environment variable (i.e.
ELECTRON_EXTRA_LAUNCH_ARGS=--remote-debugging-port=9222
) as documented here (https://docs.cypress.io/api/plugins/browser-launch-api#Modify-Electron-app-switches) that it will not get overridden with a random port.Steps to test
example
directory12.12.0
-npm i -D Cypress@12.12.0
npm i
ELECTRON_EXTRA_LAUNCH_ARGS=--remote-debugging-port=9222 npm run test
example
directory, runnpm run start
to start the example serverpackages/app
ELECTRON_EXTRA_LAUNCH_ARGS=--remote-debugging-port=9222 yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project {path_to}/cypress-har-generator/example
and switch out path to the reproduction repo where it sayspath_to
in this commandHow has the user experience changed?
N/A
PR Tasks
cypress-documentation
?type definitions
?