Skip to content

Commit

Permalink
fix: don't send if ws is not opened
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhang1030 committed May 30, 2024
1 parent e4b6d7e commit 48c2f6d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export function send<T>(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,
Expand Down

0 comments on commit 48c2f6d

Please sign in to comment.