Skip to content

Commit 271a5a9

Browse files
committed
fix: Prevent messages from being sent if the socket is closed
1 parent c5d3d19 commit 271a5a9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

deno/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ async function init() {
5454
}
5555

5656
async function sendMessage(message: any, socket: WebSocket) {
57+
if (socket.isClosed) {
58+
return;
59+
}
5760
const structured = serializeStructure(message);
5861
const json = JSON.stringify(structured);
5962
return socket.send(json);

0 commit comments

Comments
 (0)