From 50ad751e7dadaa8fdbd9674d011f730946c9d44c Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sat, 30 May 2020 13:15:12 +0200 Subject: [PATCH] Protect against stream being null in connection.close. This may happen if we close a connection before getting any tracks. --- static/sfu.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/static/sfu.js b/static/sfu.js index 0fe9793..102ae39 100644 --- a/static/sfu.js +++ b/static/sfu.js @@ -56,12 +56,14 @@ Connection.prototype.close = function(sendit) { while(this.timers.length > 0) clearInterval(this.timers.pop()); - this.stream.getTracks().forEach(t => { - try { - t.stop(); - } catch(e) { - } - }); + if(this.stream) { + this.stream.getTracks().forEach(t => { + try { + t.stop(); + } catch(e) { + } + }); + } this.pc.close(); if(sendit) {