Fix false stale Fleet reports caused by clock skew

This commit is contained in:
2026-09-19 20:17:43 -04:00
parent 345839fbd4
commit 1d073779fe
9 changed files with 224 additions and 15 deletions
+2 -2
View File
@@ -12,11 +12,11 @@ export async function GET() {
start(controller) {
unsubscribe = subscribe((event) => {
if (event.type === 'server-status' || event.type === 'server-telemetry') {
controller.enqueue(encoder.encode(`event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`));
controller.enqueue(encoder.encode(`event: ${event.type}\ndata: ${JSON.stringify({ ...event, serverNow: Date.now() })}\n\n`));
}
});
controller.enqueue(encoder.encode(': hello\n\n'));
controller.enqueue(encoder.encode(`event: server-telemetry\ndata: ${JSON.stringify({ entries: listTelemetry(), snapshot: true })}\n\n`));
controller.enqueue(encoder.encode(`event: server-telemetry\ndata: ${JSON.stringify({ entries: listTelemetry(), snapshot: true, serverNow: Date.now() })}\n\n`));
heartbeat = setInterval(() => controller.enqueue(encoder.encode(': ping\n\n')), HEARTBEAT_MS);
},
cancel() {
+1
View File
@@ -40,6 +40,7 @@ export async function GET() {
});
return json({
servers,
serverNow: Date.now(),
reservedNames: (db().prepare("SELECT j.server FROM server_creation_jobs j JOIN server_deployments d ON d.id = j.deployment_id WHERE d.state IN ('queued', 'running', 'awaiting-health')").all() as { server: string }[]).map(row => row.server),
integrations: {
rcon: rconConfigured(),
+4 -4
View File
@@ -154,9 +154,9 @@
let hasDiagnosticIssue = $derived(effectiveHealth !== 'online' && effectiveHealth !== 'starting');
function ago(iso: string | null): string {
function ago(iso: string | null, now: number): string {
if (!iso) return 'never';
const d = Date.now() - new Date(iso).getTime();
const d = now - new Date(iso).getTime();
if (d < 60_000) return `${Math.max(1, Math.floor(d / 1000))}s ago`;
if (d < 3_600_000) return `${Math.floor(d / 60_000)}m ago`;
if (d < 86_400_000) return `${Math.floor(d / 3_600_000)}h ago`;
@@ -270,7 +270,7 @@
{/if}
{#if effectiveHealth !== 'online'}
<div class="metric-cell">
<Stat label="Last seen" value={ago(effectiveSeen)} size="md" tween={false} />
<Stat label="Last seen" value={ago(effectiveSeen, $uiNow)} size="md" tween={false} />
</div>
{/if}
</div>
@@ -517,7 +517,7 @@
{/if}
</span>
<span class="hist-files">{mine.files_changed} file{mine.files_changed === 1 ? '' : 's'}</span>
<span class="hist-when">{ago(d.started_at)}</span>
<span class="hist-when">{ago(d.started_at, $uiNow)}</span>
{#if mine.error}<span class="hist-err">{mine.error}</span>{/if}
</a>
{/each}