Skip to content

Commit

Permalink
fix: check if websocket is open before writing (#22)
Browse files Browse the repository at this point in the history
Related: #23
  • Loading branch information
itsfuad authored and darrachequesne committed Jan 9, 2025
1 parent 84d97be commit d08f8f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/engine.io/lib/transports/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class WS extends Transport {
public send(packets: Packet[]) {
for (const packet of packets) {
Parser.encodePacket(packet, true, (data: RawData) => {
if (this.writable) {
if (this.writable && this.socket?.readyState === WebSocket.OPEN) {
this.socket?.send(data);
}
});
Expand Down

0 comments on commit d08f8f2

Please sign in to comment.