Fix polling interval memory leak - store all interval IDs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
erik 2026-02-26 09:17:31 +00:00
parent 230f08fab8
commit 395b7fb7ec

View file

@ -499,7 +499,7 @@ let imgW = 0, imgH = 0;
let scale = 1, offX = 0, offY = 0, minScale = 1; let scale = 1, offX = 0, offY = 0, minScale = 1;
let dragging = false, sx = 0, sy = 0; let dragging = false, sx = 0, sy = 0;
let selected = ""; let selected = "";
let pollID = null; const pollIntervals = [];
/* ---------- utility functions ----------------------------------- */ /* ---------- utility functions ----------------------------------- */
const hue = name => { const hue = name => {
@ -1449,15 +1449,21 @@ function handleServerStatusUpdate(msg) {
} }
function startPolling() { function startPolling() {
if (pollID !== null) return; // Clear any existing intervals first (prevents leak on re-init)
pollIntervals.forEach(id => clearInterval(id));
pollIntervals.length = 0;
// Initial fetches
pollLive(); pollLive();
pollTotalRares(); // Initial fetch pollTotalRares();
pollTotalKills(); // Initial fetch pollTotalKills();
pollServerHealth(); // Initial server health check pollServerHealth();
pollID = setInterval(pollLive, POLL_MS);
setInterval(pollTotalRares, POLL_RARES_MS); // Set up recurring polls
setInterval(pollTotalKills, POLL_KILLS_MS); pollIntervals.push(setInterval(pollLive, POLL_MS));
setInterval(pollServerHealth, POLL_HEALTH_MS); pollIntervals.push(setInterval(pollTotalRares, POLL_RARES_MS));
pollIntervals.push(setInterval(pollTotalKills, POLL_KILLS_MS));
pollIntervals.push(setInterval(pollServerHealth, POLL_HEALTH_MS));
} }
img.onload = () => { img.onload = () => {