Merge pull request #38 from drift-labs/ws-undefined-guard

ws guard against undefined
This commit is contained in:
wphan
2023-12-07 10:36:38 -08:00
committed by GitHub

View File

@@ -97,9 +97,11 @@ async function main() {
redisClient.client.on('message', (subscribedChannel, message) => { redisClient.client.on('message', (subscribedChannel, message) => {
const subscribers = channelSubscribers.get(subscribedChannel); const subscribers = channelSubscribers.get(subscribedChannel);
subscribers.forEach((ws) => { if (subscribers) {
ws.send(JSON.stringify({ channel: subscribedChannel, data: message })); subscribers.forEach((ws) => {
}); ws.send(JSON.stringify({ channel: subscribedChannel, data: message }));
});
}
}); });
redisClient.client.on('error', (error) => { redisClient.client.on('error', (error) => {
@@ -180,7 +182,7 @@ async function main() {
lastUpdateChannel lastUpdateChannel
); );
if (lastMessage !== null) { if (lastMessage) {
ws.send( ws.send(
JSON.stringify({ JSON.stringify({
channel: lastUpdateChannel, channel: lastUpdateChannel,