@nockdev/hsa 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard.html +34 -8
- package/package.json +1 -1
package/dashboard.html
CHANGED
|
@@ -1481,7 +1481,7 @@
|
|
|
1481
1481
|
STATE
|
|
1482
1482
|
================================================================ */
|
|
1483
1483
|
let endpoint =
|
|
1484
|
-
localStorage.getItem("hsa_endpoint") ||
|
|
1484
|
+
localStorage.getItem("hsa_endpoint") || window.location.origin;
|
|
1485
1485
|
let autoRefresh = true;
|
|
1486
1486
|
let refreshInterval = null;
|
|
1487
1487
|
let cacheHistory = [];
|
|
@@ -1491,6 +1491,9 @@
|
|
|
1491
1491
|
let selectedIde = "";
|
|
1492
1492
|
let selectedProject = "";
|
|
1493
1493
|
let sessionSSERetryMs = 1000;
|
|
1494
|
+
let sessionSSERetryCount = 0;
|
|
1495
|
+
const MAX_SSE_RETRIES = 5;
|
|
1496
|
+
let sseReconnectTimer = null;
|
|
1494
1497
|
let fetchErrorCount = 0;
|
|
1495
1498
|
const BASE_REFRESH_MS = 5000;
|
|
1496
1499
|
const MAX_REFRESH_MS = 30000;
|
|
@@ -1507,8 +1510,15 @@
|
|
|
1507
1510
|
localStorage.setItem("hsa_endpoint", endpoint);
|
|
1508
1511
|
setStatus("connecting");
|
|
1509
1512
|
fetchErrorCount = 0; // Reset error counter on manual connect
|
|
1513
|
+
sessionSSERetryCount = 0; // Reset SSE retries so reconnect works
|
|
1514
|
+
sessionSSERetryMs = 1000; // Reset backoff delay
|
|
1515
|
+
if (sseReconnectTimer) {
|
|
1516
|
+
clearTimeout(sseReconnectTimer);
|
|
1517
|
+
sseReconnectTimer = null;
|
|
1518
|
+
}
|
|
1510
1519
|
fetchDashboard();
|
|
1511
1520
|
fetchSessions();
|
|
1521
|
+
connectSessionSSE(); // Re-establish SSE stream
|
|
1512
1522
|
}
|
|
1513
1523
|
|
|
1514
1524
|
function setStatus(status) {
|
|
@@ -1553,8 +1563,11 @@
|
|
|
1553
1563
|
startRefresh();
|
|
1554
1564
|
}
|
|
1555
1565
|
function updateRefreshBadge(badge) {
|
|
1556
|
-
const ms = Math.min(
|
|
1557
|
-
|
|
1566
|
+
const ms = Math.min(
|
|
1567
|
+
BASE_REFRESH_MS * Math.pow(2, fetchErrorCount),
|
|
1568
|
+
MAX_REFRESH_MS,
|
|
1569
|
+
);
|
|
1570
|
+
badge.textContent = ms >= 1000 ? ms / 1000 + "s" : ms + "ms";
|
|
1558
1571
|
}
|
|
1559
1572
|
|
|
1560
1573
|
/* ================================================================
|
|
@@ -2152,7 +2165,10 @@
|
|
|
2152
2165
|
for (let i = 1; i < cacheHistory.length; i++) {
|
|
2153
2166
|
deltas.push({
|
|
2154
2167
|
hits: Math.max(0, cacheHistory[i].hits - cacheHistory[i - 1].hits),
|
|
2155
|
-
misses: Math.max(
|
|
2168
|
+
misses: Math.max(
|
|
2169
|
+
0,
|
|
2170
|
+
cacheHistory[i].misses - cacheHistory[i - 1].misses,
|
|
2171
|
+
),
|
|
2156
2172
|
});
|
|
2157
2173
|
}
|
|
2158
2174
|
const maxVal = Math.max(
|
|
@@ -2235,6 +2251,12 @@
|
|
|
2235
2251
|
}
|
|
2236
2252
|
|
|
2237
2253
|
function connectSessionSSE() {
|
|
2254
|
+
if (sessionSSERetryCount >= MAX_SSE_RETRIES) {
|
|
2255
|
+
console.warn(
|
|
2256
|
+
"SSE: Max retries reached, stopping session stream reconnect",
|
|
2257
|
+
);
|
|
2258
|
+
return;
|
|
2259
|
+
}
|
|
2238
2260
|
if (sessionSSE) {
|
|
2239
2261
|
sessionSSE.close();
|
|
2240
2262
|
sessionSSE = null;
|
|
@@ -2253,17 +2275,21 @@
|
|
|
2253
2275
|
}
|
|
2254
2276
|
} catch {}
|
|
2255
2277
|
};
|
|
2256
|
-
// FE-02: Auto-reconnect with exponential backoff
|
|
2278
|
+
// FE-02: Auto-reconnect with exponential backoff + max retry cap
|
|
2257
2279
|
sessionSSE.onerror = () => {
|
|
2258
2280
|
sessionSSE.close();
|
|
2259
2281
|
sessionSSE = null;
|
|
2260
|
-
|
|
2282
|
+
sessionSSERetryCount++;
|
|
2283
|
+
const delay = sessionSSERetryMs;
|
|
2284
|
+
sessionSSERetryMs = Math.min(sessionSSERetryMs * 2, 30000);
|
|
2285
|
+
sseReconnectTimer = setTimeout(() => {
|
|
2286
|
+
sseReconnectTimer = null;
|
|
2261
2287
|
connectSessionSSE();
|
|
2262
|
-
|
|
2263
|
-
}, sessionSSERetryMs);
|
|
2288
|
+
}, delay);
|
|
2264
2289
|
};
|
|
2265
2290
|
sessionSSE.onopen = () => {
|
|
2266
2291
|
sessionSSERetryMs = 1000;
|
|
2292
|
+
sessionSSERetryCount = 0;
|
|
2267
2293
|
};
|
|
2268
2294
|
} catch {}
|
|
2269
2295
|
}
|