From df2f1d1a1fb2bcfd1b11ee406fa5a73fb4148e49 Mon Sep 17 00:00:00 2001 From: Steve Axtmann Date: Wed, 22 Jan 2020 17:05:31 +0100 Subject: [PATCH 1/2] fix(Connection): switched topic with no subscriptions exception to a debug message replaced the error inside makeEventPacket to a debug message as this was blocking broadcasts from being sent when a socket connection was closed #63 --- src/Connection/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Connection/index.js b/src/Connection/index.js index c2f23f4..d631a23 100644 --- a/src/Connection/index.js +++ b/src/Connection/index.js @@ -623,7 +623,7 @@ class Connection extends Emittery { } if (!this.hasSubscription(topic)) { - throw new Error(`Topic ${topic} doesn't have any active subscriptions`) + debug('Topic %s doesn\'t have any active subscriptions', topic) } return msp.eventPacket(topic, event, data) From 9629a0ed2d0eaaeefc57e5ab1e85f08bbd27d632 Mon Sep 17 00:00:00 2001 From: Steve Axtmann Date: Wed, 22 Jan 2020 17:16:21 +0100 Subject: [PATCH 2/2] test(Connection): fixed tests relating to the makeEventPacket change fixed tests relating to the makeEventPacket change --- test/unit/connection.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/connection.spec.js b/test/unit/connection.spec.js index cccb1e2..71dd373 100644 --- a/test/unit/connection.spec.js +++ b/test/unit/connection.spec.js @@ -580,16 +580,16 @@ test.group('Connection', (group) => { helpers.startClient() }) - test('return hard error when topic has no active subscriptions on a connection', (assert, done) => { + test('does not return hard error when topic has no active subscriptions on a connection', (assert, done) => { assert.plan(1) this.ws = helpers.startWsServer() this.ws.on('connection', (ws, req) => { const connection = new Connection(ws, req, JsonEncoder) - const fn = () => connection.sendEvent('chat') + const fn = () => connection.sendEvent('chat', 'message') done(() => { - assert.throw(fn, 'Topic chat doesn\'t have any active subscriptions') + assert.doesNotThrow(fn) }) })