Browse Source

Fix destructuring error when unsubscribing without subscribing (#14566)

master
Eugen Rochko 3 years ago
committed by GitHub
parent
commit
01647b8acb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      streaming/index.js

+ 6
- 3
streaming/index.js View File

@ -210,6 +210,7 @@ const startWorker = (workerId) => {
if (subs[channel].length === 0) { if (subs[channel].length === 0) {
log.verbose(`Unsubscribe ${channel}`); log.verbose(`Unsubscribe ${channel}`);
redisSubscribeClient.unsubscribe(channel); redisSubscribeClient.unsubscribe(channel);
delete subs[channel];
} }
}; };
@ -866,19 +867,21 @@ const startWorker = (workerId) => {
channelNameToIds(request, channelName, params).then(({ channelIds }) => { channelNameToIds(request, channelName, params).then(({ channelIds }) => {
log.verbose(request.requestId, `Ending stream from ${channelIds.join(', ')} for ${request.accountId}`); 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; return;
} }
const { listener, stopHeartbeat } = subscription;
channelIds.forEach(channelId => { channelIds.forEach(channelId => {
unsubscribe(`${redisPrefix}${channelId}`, listener); unsubscribe(`${redisPrefix}${channelId}`, listener);
}); });
stopHeartbeat(); stopHeartbeat();
subscriptions[channelIds.join(';')] = undefined;
delete subscriptions[channelIds.join(';')];
}).catch(err => { }).catch(err => {
log.verbose(request.requestId, 'Unsubscription error:', err); log.verbose(request.requestId, 'Unsubscription error:', err);
socket.send(JSON.stringify({ error: err.toString() })); socket.send(JSON.stringify({ error: err.toString() }));

Loading…
Cancel
Save