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>
This commit is contained in:
2026-06-13 18:19:03 +02:00
co-authored by Copilot
parent 7ea16d4677
commit 27d67f73aa
+7 -4
View File
@@ -45,6 +45,13 @@ function ServerInfoPage(params, container) {
'</div>';
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 ----