Fix polling interval memory leak - store all interval IDs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
230f08fab8
commit
395b7fb7ec
1 changed files with 15 additions and 9 deletions
|
|
@ -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 = () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue