From 3536331f94dd38890be77f7ae2304561107c7bc5 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 3 Mar 2021 09:37:26 +0100 Subject: [PATCH] lib/client: throw error in send if disconnected --- lib/client.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/client.js b/lib/client.js index eab180d..f567c8f 100644 --- a/lib/client.js +++ b/lib/client.js @@ -341,6 +341,9 @@ export default class Client extends EventTarget { } send(msg) { + if (!this.ws) { + throw new Error("Failed to send IRC message " + msg.command + ": socket is closed"); + } this.ws.send(irc.formatMessage(msg)); console.log("Sent:", msg); }