[FIX] mail: remove the dataChannel entry when removing a peer.
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) <seb@odoo.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user