From 7380d523d5f57a616cb66e7ac05dcbddc71f0620 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 4 Feb 2020 11:39:37 +0000 Subject: [PATCH] avoid emitting when client not connected the emit is happening asynchronously after the client list is computed, so clients may have disconnected in the intervening time. --- services/real-time/app/coffee/WebsocketLoadBalancer.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/real-time/app/coffee/WebsocketLoadBalancer.coffee b/services/real-time/app/coffee/WebsocketLoadBalancer.coffee index 12b7ef812b..a93f5f9c9c 100644 --- a/services/real-time/app/coffee/WebsocketLoadBalancer.coffee +++ b/services/real-time/app/coffee/WebsocketLoadBalancer.coffee @@ -96,6 +96,9 @@ module.exports = WebsocketLoadBalancer = , (client, cb) -> Utils.getClientAttributes client, ['is_restricted_user'], (err, {is_restricted_user}) -> return cb(err) if err? + if !client.connected + logger.warn {channel:channel, client: client.id}, "skipping emit, client not connected" + return cb() if !seen[client.id] seen[client.id] = true if !(is_restricted_user && message.message not in RESTRICTED_USER_MESSAGE_TYPE_PASS_LIST)