fix: revert removeAllListeners() from destroyRoom() to stop SDK teardown errors

Closure guards on all 15 handlers already isolate React state from stale
rooms — the sledgehammer removeAllListeners() was stripping the SDK's own
internal listeners (PCManager, SignalClient), causing "Tried to add a track
for a participant that's not present" errors on rapid channel switches.
This commit is contained in:
Jannis Braun
2026-02-23 21:30:07 +01:00
parent 61e607204f
commit e9ec61db43
+1 -2
View File
@@ -107,10 +107,9 @@ function parseIdentity(identity: string): { userId: string; username: string } {
let _connectGeneration = 0; let _connectGeneration = 0;
/** Strip all listeners then disconnect — prevents ghost Room memory leaks. */ /** Null-safe Room.disconnect() wrapper — lets the SDK tear down its own internals cleanly. */
function destroyRoom(room: Room | null): Promise<void> | void { function destroyRoom(room: Room | null): Promise<void> | void {
if (!room) return; if (!room) return;
room.removeAllListeners();
return room.disconnect(); return room.disconnect();
} }