diff options
author | ThibG <thib@sitedethib.com> | 2020-08-13 23:10:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-13 23:10:19 +0200 |
commit | 6fece522f9dca9d13ae2d4437b395a92ddb106c9 (patch) | |
tree | 882f9cf298e9dffa985f214b28a877b08cf19752 /streaming/index.js | |
parent | 660188c9008761ae38d0e82dea841f7d90e199f9 (diff) | |
parent | 0f71372d6337f695a87c7158c52b93e49acc215d (diff) |
Merge pull request #1404 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'streaming/index.js')
-rw-r--r-- | streaming/index.js | 9 |
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() })); |