Skip to content

fix(desktop): remote reconnect can't latch frozen after a liveness trip (#93454, salvage #93476, prior art #40008) - #93662

Merged
teknium1 merged 6 commits into
mainfrom
salv/93454-bounded-reconnect
Aug 24, 2026
Merged

teknium1 merged 6 commits into
mainfrom
salv/93454-bounded-reconnect

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

Summary

The desktop no longer freezes on "Connecting to remote Hermes backend…" forever after a liveness-probe trip — one stuck IPC round-trip used to latch the reconnect loop permanently, requiring an app restart. Fixes #93454.

Changes

  • apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts: all three reconnect awaits (revalidateConnection, getConnection, resolveGatewayWsUrl) are timeout-bounded; on timeout reconnecting clears and the existing backoff loop resumes
  • Sibling unbounded resolveGatewayWsUrl awaits on the boot and gateway-switch paths bounded too (follow-up commit)

Validation

Before After
Stuck IPC during reconnect loop latched forever, restart required timeout → backoff retries
Tests — 21/21 (use-gateway-boot suite incl. new bounded-await tests)

Salvaged from #93476 (@chelsealong), authorship preserved. Prior art: the same fix shape was first proposed in #40008 by @victorftrdba (closed unmerged, June 2026) — credited here.

Infographic

Bounded reconnect

chelsealong and others added 4 commits August 24, 2026 00:08
…latch the UI frozen

After a liveness-probe-triggered reconnect on a remote gateway,
attemptReconnect() awaits desktop.getConnection() and resolveGatewayWsUrl()
with no timeout. If either stalls (e.g. main process wedged mid-revalidation
even though the backend itself is reachable), the `reconnecting` guard never
clears, so every later scheduleReconnect()/attemptReconnect() early-returns
forever and the UI stays stuck in "reconnecting" until the app is restarted.

Bound both awaits with a 20s timeout so a stall rejects instead of hanging;
the existing catch/finally already clears the guard and resumes backoff on
rejection. gateway.connect() keeps its own separate connect timeout.

Fixes #93454
attemptReconnect() awaited desktop.revalidateConnection?.() unbounded,
immediately before the two IPC calls the previous commit wrapped in
withTimeout(). A wedged revalidation after a liveness-probe trip -
the exact trigger #93454 and this file's own comment describe - hung
that await forever, so the reconnecting guard never cleared and the
prior fix never got reached.

Wrap it in the same 20s withTimeout() (still swallowing the result via
.catch, matching its existing best-effort semantics) and extend the
regression test to hang revalidateConnection() specifically, proving
getConnection() and the socket still proceed once the stall times out.
…waits too (#93454)

Follow-up to the reconnect-loop fix: the same unbounded ticket-mint await
exists on the soft gateway-switch path and the initial boot() path. Bound
both with the same withTimeout/RECONNECT_ATTEMPT_TIMEOUT_MS so a wedged
IPC round-trip fails into the existing retry paths instead of hanging the
switch or the 'Starting Hermes…' screen forever.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/desktop Electron desktop app (apps/desktop/*) sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Aug 24, 2026
@teknium1
teknium1 merged commit e8d5660 into main Aug 24, 2026
29 checks passed
@teknium1
teknium1 deleted the salv/93454-bounded-reconnect branch August 24, 2026 10:22
@Sora-bluesky

Copy link
Copy Markdown

Cross-reference: #73821 (open, CI green) also changes use-gateway-boot.ts and its test file: it reworks the boot() path so a gateway switch cannot resurrect a stale boot. The retry wrapping this PR adds around resolveGatewayWsUrl lands inside the same boot() region #73821 rewrites, so the two heads conflict there. I will rebase #73821 once this lands and reconcile on top of the liveness-trip latch fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop: remote gateway reconnect hangs indefinitely after liveness-probe trip, requires manual app restart

4 participants