From 27d67f73aa1509395d6608497676420c98c62345 Mon Sep 17 00:00:00 2001 From: oOHiyoriOo Date: Sat, 13 Jun 2026 18:19:03 +0200 Subject: [PATCH] fix: start polling synchronously, decoupled from nv.addGraph Move startPolling() before nv.addGraph calls so it fires immediately after DOM setup. This eliminates the race where nv.addGraph's async render loop could delay or silently swallow the polling start. Charts still initialize via nv.addGraph and have null guards in updateCharts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- js/pages/serverInfo.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/pages/serverInfo.js b/js/pages/serverInfo.js index 1ce9ed6..a8d98d8 100644 --- a/js/pages/serverInfo.js +++ b/js/pages/serverInfo.js @@ -45,6 +45,13 @@ function ServerInfoPage(params, container) { ''; container.innerHTML = html; + // Start data polling immediately — charts will render when ready + if (Rcon.isConnected()) startPolling(); + else { + var _c = function () { startPolling(); Rcon.off('connected', _c); }; + Rcon.on('connected', _c); + } + // ---- NVD3 Charts ---- nv.addGraph(function () { var perfChart = nv.models.multiChart() @@ -99,10 +106,6 @@ function ServerInfoPage(params, container) { d3.select('#chart-players').datum([]).call(playersChart); window._playersChart = playersChart; - - // All charts ready — start polling data - if (Rcon.isConnected()) startPolling(); - else { var _c = function () { startPolling(); Rcon.off('connected', _c); }; Rcon.on('connected', _c); } }); // ---- Data polling ----