diff --git a/internal/gateway/server.go b/internal/gateway/server.go index 9bd591b..1f54ce9 100644 --- a/internal/gateway/server.go +++ b/internal/gateway/server.go @@ -377,6 +377,9 @@ func (g *Gateway) handleModels(w http.ResponseWriter, r *http.Request) { } // ensureProbe triggers a live source probe at most once every 30s. +// The probe runs asynchronously so a slow/stuck upstream never blocks the +// status response — reachability data is eventually-consistent and the UI +// polls /api/stats every 3s anyway, so the next refresh picks it up. func (g *Gateway) ensureProbe(ctx context.Context) { g.probeMu.Lock() due := time.Since(g.lastProbe) > 30*time.Second @@ -384,9 +387,14 @@ func (g *Gateway) ensureProbe(ctx context.Context) { g.lastProbe = time.Now() } g.probeMu.Unlock() - if due { - g.core.Registry().ProbeAll(ctx) + if !due { + return } + go func() { + probeCtx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + g.core.Registry().ProbeAll(probeCtx) + }() } // handleResetHealth (admin) clears the per-source backoff state so a fixed