fix: clear qualityDebounceTimer on connectionStats stop (BUG-071B)

The quality debounce timer could fire after the stats poller was stopped,
calling listeners against a dead room. Sub-issues A (autoplay listener)
and C (VAD timer) were already fixed in prior work.
This commit is contained in:
jevb
2026-04-01 18:12:12 +02:00
parent 32068e06f6
commit 8907bfd6b6
@@ -190,6 +190,12 @@ export function createConnectionStatsPoller(getRoom: () => Room | null): Connect
log.info("Stopping connection stats poller");
clearInterval(intervalId);
intervalId = null;
// BUG-071B: Clear pending quality debounce timer to prevent it firing
// after the poller is stopped (would call listeners against a dead room).
if (qualityDebounceTimer !== null) {
clearTimeout(qualityDebounceTimer);
qualityDebounceTimer = null;
}
current = EMPTY_STATS;
prev = { timestamp: Date.now(), outBytes: 0, inBytes: 0 };
}