fix(update): wait for resumed Windows gateway before failing fleet check - #94580
AlexGabbia wants to merge 1 commit into
Conversation
This PR fixes a real Windows-specific race in the update command's fleet check. The old single 2-second sleep was too short for a DETACHED gateway process to boot and publish its identity, causing a false "no rows" result that triggered a destructive full retry (re-killing the gateway the first attempt just started). Replacing the fixed sleep with a bounded 30-second polling loop is the right approach. The pre-restart PID snapshot is correctly preserved through the polling loop so DOWN rows still surface for gateways that were stopped without replacement. Two concerns:
The |
The post-update fleet version check slept 2s and probed once. On Windows the resume path relaunches the gateway detached, and it needs ~10s to boot (the Telegram polling reconnect) before it stamps gateway_state.json or answers the control socket. That race reported "no rows" for a healthy resume, exited 1, and triggered a full retry that re-killed the gateway the first attempt had just started — leaving it down and surfacing "Update failed (exit 1)". Poll a bounded window (up to 30s) for the resumed gateway to publish its identity, and only treat a persistently empty snapshot as verification failure. The fail-closed contract from NousResearch#93406 is preserved: a gateway that genuinely never comes back still exits 1.
7d12570 to
ea2669c
Compare
|
Thanks for the review. I've addressed the first point — the poll now keeps waiting while any row is still down (the stale pre-restart record of a gateway whose detached replacement is still booting), so a slow second gateway can't be misread as down and re-trigger the retry. I've left the 30s deadline hardcoded for now to keep the change minimal; happy to make it configurable if maintainers prefer. |
|
Merged via #95859 (rebase merge, commit b3e477f) — your commit cherry-picked onto current main with your authorship preserved in git log, including the down-rows-keep-polling refinement from your review round, which landed exactly as you wrote it. Your root-cause read matched both independent repros on #95589 precisely: the detached Windows relaunch needs ~10s to stamp its identity while the check gave it 2, and the false exit-1 cascaded into the desktop hand-off re-killing the gateway the resume had just started. We verified with an A/B replay of that timeline — merge-base's single poll returns zero rows, your poll settles on #95589 stays open for its separate silent-stall half (the #95625 watchdog, under review). Thanks for a precise fix with the review feedback already folded in. |
Problem
On Windows, hermes update reports "Update failed (exit 1)" even though the code update completes successfully. The desktop surfaces the failure, and the handoff script (scripts/desktop-update/windows.ps1) retries the entire update.
Root cause
The post-update fleet version check (_cmd_update_impl) sleeps 2s and probes once. On Windows the resume path relaunches the gateway detached, and it needs ~10s to boot (the Telegram polling reconnect) before it stamps gateway_state.json or answers the control socket. The probe therefore finds zero rows for a healthy resume, _fleet_probe_expected_runtimes() reports "verification incomplete", and the update exits 1.
The retry then pauses the gateway the first attempt had just started, killing it, and repeats the cycle — leaving the user with a stopped gateway and a spurious failure message.
Fix
Poll a bounded window (up to 30s) for the resumed gateway to publish its identity instead of probing once. Only a persistently empty snapshot is treated as verification failure, so the #93406 fail-closed contract is preserved (a gateway that genuinely never comes back still exits 1).
Test plan