From 48c2f6d00be466523363dd92fe921de10d3c2495 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 30 May 2024 14:21:00 +0800 Subject: [PATCH] fix: don't send if ws is not opened --- src/send.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/send.ts b/src/send.ts index 7d33e86..e6b904b 100644 --- a/src/send.ts +++ b/src/send.ts @@ -12,6 +12,11 @@ export function send(ws: WebSocket, config: ResolvedWSHEConfig, eventName: st }, timeout) } + // if the connection is not open, do not send the message + if (ws.readyState !== WebSocket.OPEN) { + return + } + ws.send(withSign(JSON.stringify({ event: eventName, data,