fix(fleet): make local self-update flow reliable end-to-end (#472)

The "Updating Sencho..." overlay used to dismiss prematurely while the
image pull was still running, after which the local node card would get
stuck in "updating" and eventually surface a generic "Timed Out" error
while the container remained on the old version.

Three root causes are addressed:

1. The image pull was synchronous (`execFileSync`), which blocked the
   Node event loop. The overlay's health probe saw the server come back
   the moment the pull finished and reloaded the page, even though the
   container had not restarted yet. The pull is now async via
   `promisify(execFile)`, so /api/health and /api/fleet/update-status
   keep serving throughout.

2. The overlay reloaded on the first 200 from /api/health regardless of
   whether the underlying process had actually restarted. /api/health
   now exposes the gateway boot timestamp, and the overlay captures it
   pre-update and only reloads when it observes a different value. A
   wasOffline-then-online fallback handles the case where the pre-update
   fetch failed.

3. Helper container spawn errors from `docker run` were silently
   discarded, so a failed compose recreate never surfaced anywhere.
   Errors are now captured into `lastUpdateError` via the execFile
   callback and surfaced through the existing /api/fleet/update-status
   error path.

A 3-minute early-fail heuristic on the local node block surfaces a clear
failure message when the helper fails silently, instead of waiting the
full 5-minute timeout for an unknown failure.
This commit is contained in:
Anso
2026-04-10 12:00:44 -04:00
committed by GitHub
parent c09673d8bb
commit 3d69746eee
5 changed files with 103 additions and 22 deletions
+12
View File
@@ -44,6 +44,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
* **fleet:** fix local (gateway) self-update flow end-to-end. The "Updating Sencho..."
overlay no longer dismisses prematurely while the image pull is still running; it now
compares the gateway's boot timestamp via `/api/health` and only reloads after a real
container restart is observed. The image pull was made fully async so the API stays
responsive throughout (previously a sync `execFileSync` blocked the event loop, which
caused the overlay to reload the moment the pull finished, while still on the old
process). Helper container spawn errors are now captured into `lastUpdateError` instead
of being silently swallowed, so a failed `docker run` for the compose recreate surfaces
immediately on the Fleet Overview. A 3-minute early-fail heuristic surfaces a clear
failure message when the helper container fails silently, instead of users waiting the
full 5-minute timeout for an unknown failure.
* **api:** add tiered rate limiting to prevent dashboard polling lockouts. High-frequency
polling endpoints (stats, system stats, stack statuses) are now exempt from the global
rate limiter and governed by a separate 300 req/min safety net. The global limit is