Skip to content

Commit

Permalink
fix: Plugin error when sending on disconnected IPC channel (#21011)
Browse files Browse the repository at this point in the history
* fix: Plugin error when sending on disconnected IPC channel

* Add unit test for new no send behaviour

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
  • Loading branch information
tomudding and emilyrohrbough committed Apr 13, 2022
1 parent 476f2ad commit 57dbc17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/server/lib/plugins/util.js
Expand Up @@ -25,7 +25,7 @@ module.exports = {

return {
send (event, ...args) {
if (aProcess.killed) {
if (aProcess.killed || !aProcess.connected) {
return
}

Expand Down
8 changes: 8 additions & 0 deletions packages/server/test/unit/plugins/util_spec.js
Expand Up @@ -10,6 +10,7 @@ describe('lib/plugins/util', () => {
this.theProcess = {
send: sinon.spy(),
on: sinon.stub(),
connected: true,
}

this.ipc = util.wrapIpc(this.theProcess)
Expand All @@ -31,6 +32,13 @@ describe('lib/plugins/util', () => {
expect(this.theProcess.send).not.to.be.called
})

it('#send does not send if process has been disconnected', function () {
this.theProcess.connected = false
this.ipc.send('event-name')

expect(this.theProcess.send).not.to.be.called
})

it('#on listens for process messages that match event', function () {
const handler = sinon.spy()

Expand Down

3 comments on commit 57dbc17

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 57dbc17 Apr 13, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.5/linux-x64/develop-57dbc170e6d28fb9ec168ad9df94d2c78b1e553d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 57dbc17 Apr 13, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.5/darwin-x64/develop-57dbc170e6d28fb9ec168ad9df94d2c78b1e553d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 57dbc17 Apr 13, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.5.5/win32-x64/develop-57dbc170e6d28fb9ec168ad9df94d2c78b1e553d/cypress.tgz

Please sign in to comment.