Skip to content

Commit

Permalink
fix: do not override electron debug port if previously set (#27169)
Browse files Browse the repository at this point in the history
* fix: do not override electron debug port if previously set

* Add changelog

* Update cli/CHANGELOG.md

Co-authored-by: Mike Plummer <[email protected]>

* Removed unneeded return value

---------

Co-authored-by: Mike Plummer <[email protected]>
  • Loading branch information
warrensplayer and mike-plummer committed Jun 30, 2023
1 parent 4eaf75c commit e65a3e3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ _Released 07/05/2023 (PENDING)_
- Fixed a race condition that was causing a GraphQL error to appear on the [Debug page](https://docs.cypress.io/guides/cloud/runs#Debug) when viewing a running Cypress Cloud build. Fixed in [#27134](https://github.com/cypress-io/cypress/pull/27134).
- Fixed a race condition in electron where the test window exiting prematurely during the browser launch process was causing the whole test run to fail. Addressed in [#27167](https://github.com/cypress-io/cypress/pull/27167).
- Fixed minor issues with Typescript types in the CLI. Fixes [#24110](https://github.com/cypress-io/cypress/issues/24110).
- Fixed an issue where a value for the Electron debug port would not be respected if defined using the `ELECTRON_EXTRA_LAUNCH_ARGS` environment variable. Fixes [#26711](https://github.com/cypress-io/cypress/issues/26711).

**Dependency Updates:**

- Update dependency semver to ^7.5.3. Addressed in [#27151](https://github.com/cypress-io/cypress/pull/27151).
- Update dependency semver to ^7.5.3. Addressed in [#27151](https://github.com/cypress-io/cypress/pull/27151).

## 12.16.0

Expand Down
9 changes: 8 additions & 1 deletion packages/server/lib/util/electron-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ const getRemoteDebuggingPort = () => {

const setRemoteDebuggingPort = async () => {
try {
const port = await getPort()
const { app } = require('electron')

// 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))
} catch (err) {
Expand Down
1 change: 1 addition & 0 deletions packages/server/test/support/helpers/electron_stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
exit () {},
commandLine: {
appendSwitch () {},
getSwitchValue () {},
appendArgument () {},
},
disableHardwareAcceleration () {},
Expand Down
36 changes: 36 additions & 0 deletions packages/server/test/unit/util/electron-app_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const electronApp = require('../../../lib/util/electron-app')

describe('/lib/util/electron-app', () => {
context('remote debugging port', () => {
beforeEach(() => {
sinon.restore()
})

it('should not override port if previously set', async () => {
const { app } = require('electron')

sinon.stub(app.commandLine, 'appendSwitch')
sinon.stub(app.commandLine, 'getSwitchValue').callsFake((args) => {
return '4567'
})

await electronApp.setRemoteDebuggingPort()

expect(app.commandLine.appendSwitch).to.not.have.been.called
})

it('should assign random port if not previously set', async () => {
const { app } = require('electron')

sinon.stub(app.commandLine, 'appendSwitch')

sinon.stub(app.commandLine, 'getSwitchValue').callsFake((args) => {
return undefined
})

await electronApp.setRemoteDebuggingPort()

expect(app.commandLine.appendSwitch).to.have.been.calledWith('remote-debugging-port', sinon.match.string)
})
})
})

5 comments on commit e65a3e3

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e65a3e3 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.0/linux-arm64/develop-e65a3e348a9ba386032263cb4af5934e28071b67/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e65a3e3 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.0/linux-x64/develop-e65a3e348a9ba386032263cb4af5934e28071b67/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e65a3e3 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.0/darwin-x64/develop-e65a3e348a9ba386032263cb4af5934e28071b67/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e65a3e3 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.0/darwin-arm64/develop-e65a3e348a9ba386032263cb4af5934e28071b67/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e65a3e3 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.17.0/win32-x64/develop-e65a3e348a9ba386032263cb4af5934e28071b67/cypress.tgz

Please sign in to comment.