fix(maestro): stop retrying a WS attach that never opened
Integration review (#168): a rejected attach handshake — a dormant session's 409 not_attachable, most likely — looks identical to a dropped stream from the WebSocket API (close code 1006, no reason). shouldRetryClose kept retrying it on the catalog's Running/Dead check alone, which loops for as long as the catalog hasn't caught up with the session going dormant. Track whether the socket ever reached `open`; a handshake that never did is a rejection, not a blip, so it is never retried regardless of catalog status. The caller (wired up in the next commit) gets a distinct onNeverAttached callback instead of onClosed, so it can offer the resume affordance rather than assuming the session is gone.
This commit is contained in:
@@ -26,7 +26,15 @@ export function shouldRetryClose(
|
||||
sessionId: Uuid,
|
||||
code: number,
|
||||
sessions: ReadonlyMap<Uuid, Session>,
|
||||
/** Did this socket ever reach `open`? A handshake that never completed is
|
||||
* the daemon rejecting the attach (dormant/unknown) rather than a dropped
|
||||
* stream — retrying it spins in place until the catalog updates, which for
|
||||
* a dormant session it never will (#168 review). Defaults to `true` so
|
||||
* existing callers that only track drops of an established link are
|
||||
* unaffected. */
|
||||
everOpened = true,
|
||||
): boolean {
|
||||
if (code >= APPLICATION_CLOSE || code === CLEAN_CLOSE) return false;
|
||||
if (!everOpened) return false;
|
||||
return sessions.get(sessionId)?.status === "Running";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user