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

fix: Plugin error when sending on disconnected IPC channel #21011

Merged
merged 3 commits into from Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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