From 3305b418c997aaa042436fcadf640b80d7a402e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baki=20Burak=20=C3=96=C4=9F=C3=BCn?= <63836730+bakiburakogun@users.noreply.github.com> Date: Mon, 24 Aug 2026 16:04:47 +0300 Subject: [PATCH] fix(call): guard against a missing local state broadcaster when leaving a call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- src/utils/webrtc/webrtc.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/webrtc/webrtc.js b/src/utils/webrtc/webrtc.js index 91869c50964..da3f2b397fd 100644 --- a/src/utils/webrtc/webrtc.js +++ b/src/utils/webrtc/webrtc.js @@ -525,8 +525,10 @@ export function initWebRtc(signaling, _callParticipantCollection, _localCallPart // is received before the "leave call" request ends. localUserInCall = false - localStateBroadcaster.destroy() - localStateBroadcaster = null + if (localStateBroadcaster) { + localStateBroadcaster.destroy() + localStateBroadcaster = null + } }) signaling.on('leaveCall', function(token, reconnect) { // When the MCU is used and there is a connection error the call is