This commit is contained in:
Robert Chacon committed 2026-03-15 14:46:54 -06:00
1 parent 8e7be814bd
commit 3dd3a2fb30
2 files changed
+31 -2

No files matched your search

@@ -11,7 +11,7 @@ const MIN_POINTS = 3;
const MIN_TOTAL_BYTES = 1_000_000;
const CLUSTER_PREVIEW_LIMIT = 3;
const COUNTRIES_GEOJSON_PATH = "vendor/countries.geojson";
const FLOW_MAP_PROFILE = true;
const FLOW_MAP_PROFILE = false;
const DEFAULT_POINT_OF_VIEW = {
lat: 18,
lng: -32,
@@ -24,12 +24,31 @@ function escapeAttr(text) {
}
const SCHEDULER_STATUS_POLL_MS = 2000;
const SCHEDULER_STATUS_TIMEOUT_MS = 2500;
const SCHEDULER_STATUS_STARTING_GRACE_MS = 30000;
let schedulerStatusPollTimer = null;
let schedulerStatusRequestInFlight = false;
let schedulerStatusFirstRequestedAt = null;
let schedulerStatusHealthy = false;
function listenOnceWithTimeout(eventName, timeoutMs, handler, onTimeout) {
let done = false;
const wrapped = (msg) => {
if (done) return;
done = true;
clearTimeout(timer);
wsClient.off(eventName, wrapped);
handler(msg);
};
const timer = setTimeout(() => {
if (done) return;
done = true;
wsClient.off(eventName, wrapped);
onTimeout();
}, timeoutMs);
wsClient.on(eventName, wrapped);
}
function renderSchedulerStatus(container, state) {
if (!container) return;
@@ -94,7 +113,7 @@ function loadSchedulerStatus(force = false) {
}
schedulerStatusRequestInFlight = true;
listenOnce("SchedulerStatus", (msg) => {
listenOnceWithTimeout("SchedulerStatus", SCHEDULER_STATUS_TIMEOUT_MS, (msg) => {
schedulerStatusRequestInFlight = false;
if (!msg || !msg.data) return;
const data = msg.data;
@@ -122,6 +141,16 @@ function loadSchedulerStatus(force = false) {
renderSchedulerStatus(container, "unavailable");
}
scheduleNextSchedulerStatusPoll();
}, () => {
schedulerStatusRequestInFlight = false;
schedulerStatusHealthy = false;
const elapsed = schedulerStatusFirstRequestedAt === null ? 0 : (Date.now() - schedulerStatusFirstRequestedAt);
if (elapsed < SCHEDULER_STATUS_STARTING_GRACE_MS) {
renderSchedulerStatus(container, "loading");
} else {
renderSchedulerStatus(container, "unavailable");
}
scheduleNextSchedulerStatusPoll();
});
wsClient.send({ SchedulerStatus: {} });
}