From e6fbdb91c8f074be4f463aac2ccdf8236dd46bdd Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Mon, 4 Oct 2021 08:57:07 +0000 Subject: [PATCH] [FIX] mail: remove the dataChannel entry when removing a peer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the entry in `mailRtc._dataChannels` was not removed when removing a peer, which meant that `mailRtc._dataChannels` could contain old closed dataChannels. Moreover, the call to `close()` on the dataChannel was not guarded, which could lead to tracebacks. For example, if a peer was removed before creating its dataChannel (like in crashes or successive connection recovery attempts), `close()` was called on `undefined`. this commit fixes this issue. closes odoo/odoo#77880 X-original-commit: da3fce19157a07fc1abbb6d188746d4a00d3a344 Signed-off-by: Sébastien Theys (seb) --- addons/mail/static/src/models/rtc/rtc.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/models/rtc/rtc.js b/addons/mail/static/src/models/rtc/rtc.js index e9167f56d7d..2a10cde271f 100644 --- a/addons/mail/static/src/models/rtc/rtc.js +++ b/addons/mail/static/src/models/rtc/rtc.js @@ -772,9 +772,12 @@ function factory(dependencies) { if (rtcSession) { rtcSession.reset(); } - const peerConnection = this._peerConnections[token]; const dataChannel = this._dataChannels[token]; - dataChannel.close(); + if (dataChannel) { + dataChannel.close(); + } + delete this._dataChannels[token]; + const peerConnection = this._peerConnections[token]; if (peerConnection) { this._removeRemoteTracks(peerConnection); peerConnection.close();