about summary refs log tree commit diff
path: root/streaming
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2020-08-13 22:17:29 +0200
committerThibaut Girka <thib@sitedethib.com>2020-08-13 22:17:29 +0200
commitda62e350e0b4bcf1f683c48169294d761fd901f1 (patch)
tree14709b118d680ffc93ee12620565087397190b27 /streaming
parent660188c9008761ae38d0e82dea841f7d90e199f9 (diff)
parent0f38f9726a0a9d8e13633424d03e79f54df047a4 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'streaming')
-rw-r--r--streaming/index.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/streaming/index.js b/streaming/index.js
index f5c9b4224..3a68e6de5 100644
--- a/streaming/index.js
+++ b/streaming/index.js
@@ -210,6 +210,7 @@ const startWorker = (workerId) => {
     if (subs[channel].length === 0) {
       log.verbose(`Unsubscribe ${channel}`);
       redisSubscribeClient.unsubscribe(channel);
+      delete subs[channel];
     }
   };
 
@@ -888,19 +889,21 @@ const startWorker = (workerId) => {
     channelNameToIds(request, channelName, params).then(({ channelIds }) => {
       log.verbose(request.requestId, `Ending stream from ${channelIds.join(', ')} for ${request.accountId}`);
 
-      const { listener, stopHeartbeat } = subscriptions[channelIds.join(';')];
+      const subscription = subscriptions[channelIds.join(';')];
 
-      if (!listener) {
+      if (!subscription) {
         return;
       }
 
+      const { listener, stopHeartbeat } = subscription;
+
       channelIds.forEach(channelId => {
         unsubscribe(`${redisPrefix}${channelId}`, listener);
       });
 
       stopHeartbeat();
 
-      subscriptions[channelIds.join(';')] = undefined;
+      delete subscriptions[channelIds.join(';')];
     }).catch(err => {
       log.verbose(request.requestId, 'Unsubscription error:', err);
       socket.send(JSON.stringify({ error: err.toString() }));