Skip to content

Commit 0cdf8be

Browse files
committed
fix(call): guard against a missing local state broadcaster when leaving a call
The "beforeLeaveCall" handler assumes that "beforeJoinCall" ran before it and left a broadcaster behind. The variable is null whenever the call was not joined in this page session, and it is set back to null after the first leave. leaveRoom() calls leaveCurrentCall() unconditionally, so leaving or switching a conversation reaches the handler either way and raises "Cannot read properties of null (reading 'destroy')". The exception is raised inside the promise chain of leaveCall(), so it aborts whatever the caller was doing, for example the switchto handling that moves participants to another conversation when a one-to-one conversation is extended into a group conversation. Signed-off-by: Baki Burak Öğün <63836730+bakiburakogun@users.noreply.github.com>
1 parent c66614e commit 0cdf8be

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/utils/webrtc/webrtc.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,10 @@ export function initWebRtc(signaling, _callParticipantCollection, _localCallPart
525525
// is received before the "leave call" request ends.
526526
localUserInCall = false
527527

528-
localStateBroadcaster.destroy()
529-
localStateBroadcaster = null
528+
if (localStateBroadcaster) {
529+
localStateBroadcaster.destroy()
530+
localStateBroadcaster = null
531+
}
530532
})
531533
signaling.on('leaveCall', function(token, reconnect) {
532534
// When the MCU is used and there is a connection error the call is

0 commit comments

Comments
 (0)