From bfcba853366c76940b4cd2ed27bb30e9cfb1a968 Mon Sep 17 00:00:00 2001 From: Luciano Iam Date: Sun, 12 Apr 2020 14:51:54 +0200 Subject: [PATCH] WebSockets: throw error if trying to send() before open() in MessageChannel --- share/web_surfaces/shared/channel.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/web_surfaces/shared/channel.js b/share/web_surfaces/shared/channel.js index ae02aad8bd..99a80fd354 100644 --- a/share/web_surfaces/shared/channel.js +++ b/share/web_surfaces/shared/channel.js @@ -61,7 +61,11 @@ export class MessageChannel { } send (msg) { - this.socket.send(msg.toJsonText()); + if (this.socket) { + this.socket.send(msg.toJsonText()); + } else { + throw Error('MessageChannel: cannot call send() before open()'); + } } closeCallback () {