From e9ec61db433990630be33de334469defed032f2f Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Mon, 23 Feb 2026 21:30:07 +0100 Subject: [PATCH] fix: revert removeAllListeners() from destroyRoom() to stop SDK teardown errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- packages/web/src/hooks/useLiveKit.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/web/src/hooks/useLiveKit.ts b/packages/web/src/hooks/useLiveKit.ts index fa78bd29..be11111e 100644 --- a/packages/web/src/hooks/useLiveKit.ts +++ b/packages/web/src/hooks/useLiveKit.ts @@ -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 { if (!room) return; - room.removeAllListeners(); return room.disconnect(); }