From 754fb16da0759d3141f630e487404b9e2f4f4830 Mon Sep 17 00:00:00 2001 From: tjs Date: Thu, 17 Aug 2023 16:13:12 -0400 Subject: [PATCH] add check before connect on stream --- apis/birdeye/streaming.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apis/birdeye/streaming.ts b/apis/birdeye/streaming.ts index cbd12fe6..254e3d34 100644 --- a/apis/birdeye/streaming.ts +++ b/apis/birdeye/streaming.ts @@ -67,15 +67,19 @@ export function subscribeOnStream( quoteAddress: symbolInfo.quote_token, }, } + if (!isOpen(socket)) { console.warn('Socket Closed') socket.addEventListener('open', (_event) => { + if (!msg.data.baseAddress || msg.data.quoteAddress) return socket.send(JSON.stringify(msg)) }) return } console.warn('[subscribeBars birdeye]') - socket.send(JSON.stringify(msg)) + if (msg.data.baseAddress && msg.data.quoteAddress) { + socket.send(JSON.stringify(msg)) + } } export function unsubscribeFromStream() {