Conversation
When the CLI server process dies, the SDK's StartCliServerAsync calls Process.HasExited on a stale handle, throwing InvalidOperationException: 'No process is associated with this object.' This error was not recognized by RestorePreviousSessionsAsync's fallback logic, causing worker sessions like fiesta-worker-1 to be silently dropped during resume. Changes: - Add IsProcessError() helper to detect stale process handle exceptions - Include IsProcessError in IsConnectionError() so retry logic works across all call sites (SendPromptAsync, CreateSessionAsync, etc.) - Add IsProcessError check to RestorePreviousSessionsAsync fallback condition so affected sessions get recreated via CreateSessionAsync - Add 9 regression tests covering process error detection, wrapping in AggregateException, inner exceptions, negative cases, and a structural guard for the restore fallback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
PR #374 Review — fix: handle stale CLI process error during worker session resume Sev Location Finding Consensus1 🟡 ConnectionRecoveryTests.cs:~444 Structural test uses Substring(conditionIndex, 500) — fragile fixed window that can ArgumentOutOfRangeException or false-fail if code shifts. Tests source text, not behavior. 5/5 |
Replace fragile Substring(conditionIndex, 500) with IndexOf("IsProcessError", conditionIndex),
eliminating the ArgumentOutOfRangeException risk and the fixed-window brittleness.
Also fix conditionIndex > 0 to conditionIndex != -1 for correct IndexOf semantics.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Problem
When the CLI server process dies, the SDK's \StartCliServerAsync\ calls \Process.HasExited\ on a stale handle, throwing:
\
System.InvalidOperationException: No process is associated with this object.
\
This error was not recognized by \RestorePreviousSessionsAsync's fallback logic, so worker sessions (e.g., \iesta-worker-1) were silently dropped during resume — causing orchestration to fail.
Root Cause
The catch block in \RestorePreviousSessionsAsync\ only handled three error patterns: \Session not found, \corrupt, and \session file. The process-related \InvalidOperationException\ matched none of them and also wasn't classified as a connection error by \IsConnectionError().
Fix
Tests
Added 9 regression tests in \ConnectionRecoveryTests.cs:
All 2570 tests pass. Windows build succeeds.