From 4baa3f5588e122c73d0ec8cba966199aafe87edf Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Fri, 4 Aug 2023 16:31:13 +0400 Subject: [PATCH] Fix rare error with ws.close() --- www/video-rtc.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/www/video-rtc.js b/www/video-rtc.js index dfb4228a..a259962e 100644 --- a/www/video-rtc.js +++ b/www/video-rtc.js @@ -551,12 +551,16 @@ export class VideoRTC extends HTMLElement { this.pcState = WebSocket.OPEN; this.wsState = WebSocket.CLOSED; - this.ws.close(); - this.ws = null; + if (this.ws) { + this.ws.close(); + this.ws = null; + } } else { this.pcState = WebSocket.CLOSED; - this.pc.close(); - this.pc = null; + if (this.pc) { + this.pc.close(); + this.pc = null; + } } }