fix(call): guard against a missing local state broadcaster when leaving a call - #19083
fix(call): guard against a missing local state broadcaster when leaving a call#19083bakiburakogun wants to merge 1 commit into
Conversation
…ng 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 <burak@burakogun.com>
|
Tested in production. I applied the equivalent change to the shipped bundle on our instance (Nextcloud 34.0.3, Talk 24.0.4, external signaling v2.1.1, four signaling servers) and reran the scenario from #19081. With the null check in place the call now continues after a one-to-one conversation is extended into a group conversation: the two sessions leave the old room, join the new one, and the call is re-established one second later. The participant who was just added joins the call as well. Details and the signaling timeline are in #19081 (comment) The So this change is not only a defensive guard, it also resolves that issue in our tests. I left the issue open rather than marking it fixed here, in case you consider the underlying ordering worth a closer look. |
Fixes an uncaught
TypeError: Cannot read properties of null (reading 'destroy')raised by thebeforeLeaveCallhandler insrc/utils/webrtc/webrtc.js.localStateBroadcasteris created in thebeforeJoinCallhandler and set back to null at the end ofbeforeLeaveCall, but the leave handler dereferences it without checking. It is null in at least two situations: when the call was never joined in this page session, and when the leave path runs a second time.leaveRoom()callsleaveCurrentCall()unconditionally, so simply leaving or switching a conversation reaches the handler either way.The exception is raised inside the promise chain of
leaveCall(), so it aborts whatever the caller was doing. We ran into it while investigating #19081, where adding a participant to a one-to-one conversation during a call moves everyone to the new group conversation but the call does not continue there. The stack from that reproduction:The change only adds the missing null check. When the broadcaster exists the behaviour is unchanged.
I have not verified that this alone makes the call continue in #19081, so I am not closing that issue with this pull request. The exception is wrong on its own and swallowing it is not the goal, guarding the dereference is.
Environment where this was observed: Nextcloud 34.0.3, Talk 24.0.4, external signaling server v2.1.1.