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:
@@ -107,10 +107,9 @@ function parseIdentity(identity: string): { userId: string; username: string } {
|
||||
|
||||
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 {
|
||||
if (!room) return;
|
||||
room.removeAllListeners();
|
||||
return room.disconnect();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user