From 70f9f0ccfa88764946976b40897d6a8dbb7be115 Mon Sep 17 00:00:00 2001 From: Lukas Wuttke Date: Mon, 20 Jul 2026 15:57:14 +0200 Subject: [PATCH] =?UTF-8?q?fix(home):=20give=20the=20heartbeat=20a=20reali?= =?UTF-8?q?stic=20timeout=20so=20"=C2=B7=20Online"=20stops=20flickering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `tb`/`tracebloc` flickered between "· Online" and "running — couldn't confirm it's connected to tracebloc" on identical back-to-back runs against a healthy environment. The home heartbeat probe (realHeartbeat -> GetClient) is a backend round-trip, and every invocation is a fresh process, so it pays a cold DNS+TCP+TLS handshake each time — which alone can approach a second. At the old homeProbeTimeout=1200ms / homeDetectBudget=1500ms caps the cold round-trip sometimes overran, yielding beatUnknown -> the alarming "couldn't confirm" even though the client was online. (A flicker proves a timeout, not a persistent client-id/404 issue.) Raise homeProbeTimeout to 3s and homeDetectBudget to 3.5s. The fast path is unchanged — collectProbes returns as soon as both probes report, so a quick probe still renders immediately; only a genuinely slow/unreachable backend waits longer, and then "couldn't confirm" is accurate. home.go was at its 850-line file-budget ceiling, so bump it to 855 for the added rationale comment (home.go is a split candidate — cli#282 pattern). Fixes tracebloc/cli#357. Part of epic tracebloc/backend#1142. Co-Authored-By: Claude Opus 4.8 --- internal/cli/home.go | 8 ++++++-- scripts/file-budget.sh | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/cli/home.go b/internal/cli/home.go index 71c88da2..7f268598 100644 --- a/internal/cli/home.go +++ b/internal/cli/home.go @@ -68,9 +68,13 @@ const ( // Detection is bounded so bare `tracebloc` stays snappy even when the cluster or // backend is unreachable. homeProbeTimeout caps each individual probe; // homeDetectBudget caps the whole detection regardless of any single probe. +// These must clear a COLD round-trip: the heartbeat hits the backend and every +// `tb` run is a fresh process (fresh DNS+TCP+TLS, ~1s), so the old 1200ms cap +// made a healthy "· Online" flicker to "couldn't confirm" (cli#357) — don't +// lower them back. Fast path is unaffected: collectProbes returns once both report. const ( - homeDetectBudget = 1500 * time.Millisecond - homeProbeTimeout = 1200 * time.Millisecond + homeDetectBudget = 3500 * time.Millisecond + homeProbeTimeout = 3000 * time.Millisecond ) // gpuResource is the allocatable key NVIDIA's device plugin advertises; summed diff --git a/scripts/file-budget.sh b/scripts/file-budget.sh index 290979c4..a55ded32 100755 --- a/scripts/file-budget.sh +++ b/scripts/file-budget.sh @@ -24,7 +24,7 @@ BUDGETS=" internal/push/preflight.go:1700 internal/cli/data.go:500 internal/cli/client.go:1050 -internal/cli/home.go:850 +internal/cli/home.go:855 " status=0