From c9a415c469f3080c820e92b721b3b4b872148a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 13 Oct 2018 18:26:08 -0400 Subject: [PATCH] check if process.send exists --- src/pubsub.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pubsub.js b/src/pubsub.js index 6f2af3dae8..59ab8507c9 100644 --- a/src/pubsub.js +++ b/src/pubsub.js @@ -18,11 +18,15 @@ function get() { } else if (nconf.get('singleHostCluster')) { pubsub = new EventEmitter(); pubsub.publish = function (event, data) { - process.send({ - action: 'pubsub', - event: event, - data: data, - }); + if (process.send) { + process.send({ + action: 'pubsub', + event: event, + data: data, + }); + } else { + pubsub.emit(event, data); + } }; process.on('message', function (message) { if (message && typeof message === 'object' && message.action === 'pubsub') {