You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "me2seeks (via GitHub)" <gi...@apache.org> on 2026/09/04 09:34:21 UTC

[I] fix(desktop): stale active Session observation blocks every Runtime Host reconnect after the Host forgets the Session [maka]

me2seeks opened a new issue, #4758:
URL: https://github.com/apache/maka/issues/4758

   ## Summary
   
   When the desktop main process loses its IPC connection to the Runtime Host and a previously observed Session no longer exists on the Host side (Host restart with ephemeral state, Session GC, deletion by another client), the reconnect path enters an **infinite reconnect loop**: every replacement candidate fails to start with `Failed to restore Session observations: <sessionId>`, exits, and is replaced again. Meanwhile all renderer IPC (`connections:getSnapshot`, `taskReadiness:getSnapshot`, `shell-runs:list`, …) fails with `RuntimeHostHandlerUnavailableError`.
   
   ## Root cause
   
   `RuntimeHostSessionObservationRegistry` registrations carry a `lifecycle: "pending" | "active"`. On reconnect, `desktop-manager` hands the surviving registry (`target.observations`) to each new candidate, whose `attach()` replays every registration via `subscription.open`:
   
   - Server side, a gone Session deterministically fails with `subscription.open` / `not_found` (`packages/runtime-host/src/server/session-continuity-coordinator.ts`, `#open`: "Session was not found").
   - In `RuntimeHostSessionObservationRegistry.attach()` (`apps/desktop/src/main/runtime-host-session-observation-registry.ts`), the failure cleanup only deletes registrations whose lifecycle is `"pending"`. A stale **active** registration is left in the map.
   - The candidate computes `failedSessionIds = observedSessionIds − restoredSessionIds` and throws `Failed to restore Session observations: …` (`apps/desktop/src/main/runtime-host-desktop-candidate.ts:708-715`), aborting the candidate start.
   - The reconnect lifecycle (`packages/runtime-host/src/client/reconnect-lifecycle.ts`, `#reconnect`) only treats `RuntimeHostPermanentReconnectError` as terminal; this plain error just increments the backoff and tries the next candidate — with the same stale registration still in `target.observations`. Loop forever.
   
   Note the asymmetry is intentional elsewhere: `session.transcript.page` / `not_found` *is* treated as recoverable in `isRecoverableSubscriptionFailure` (`runtime-host-session-subscription-owner.ts:425`), because a transcript page can arrive later. But `subscription.open` / `not_found` during attach is terminal — the Session itself is gone.
   
   ## Observed log signature
   
   ```
   Failed to restore Session observations: 3ee6229c-3223-479d-9c86-b1b504bbbf5c
   candidate exited cleanly { pid: …, code: 0, signal: null }   (repeats)
   RuntimeHostHandlerUnavailableError: Runtime Host handler remained unavailable after the reconnection window
   ```
   
   ## Proposed fix
   
   In the registry's `attach()` catch path, recognize `RuntimeHostOperationError` with `operation === "subscription.open"` and `code === "not_found"` as "the Host no longer serves this Session": forget the registration regardless of lifecycle and notify the upper layer so it can emit a `deleted` sessions-changed event (the renderer already handles `deleted` safely by refreshing the catalog and retiring the session view). All other failures keep the current behavior, so genuinely transient restore failures still fail the candidate and retry.
   
   I have the fix + a regression test ready and will open a PR shortly.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [I] fix(desktop): stale active Session observation blocks every Runtime Host reconnect after the Host forgets the Session [maka]

Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks closed issue #4758: fix(desktop): stale active Session observation blocks every Runtime Host reconnect after the Host forgets the Session
URL: https://github.com/apache/maka/issues/4758


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org