fix(model-auto-router): treat stalled stream as transient failure, enabling failover #12
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
weisanju/pi-plugins!12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "copilot/fix-stalled-stream-error-handling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When a provider accepts a connection but sends no SSE events for
stallTimeoutMs, the watchdog was hardcoded tofatal— callingpushError/finishRunSummarydirectly and bypassing the failover machinery entirely. A stall is operationally identical to a transient upstream timeout, so all configured backup targets were wasted.Changes
src/index.ts+dist/index.jsWatchdog callback: removed
logEvent({ event: "fatal" }),pushError(), andfinishRunSummary(). Replaced with two per-iteration flags (stalledByWatchdog,stallError). Still setsended.done = trueand callsiterator.return()to unblock the frozenawait iterator.next().selectedState.active(watchdog +finally). The new path relies solely on thefinallyblock, which always runs.Post-try/finally guard: changed
if (ended.done || committed)→if (committed || (ended.done && !stalledByWatchdog))so a watchdog stall no longer short-circuits the request.New stall failover block: when
stalledByWatchdog, adds the target totried, records it intransientFailures, incrementsfailovers, and emits a"failover"log event — feeding the existing retry/backoff/all-failed machinery.test/e2e/model-auto-router.test.tsbasicroute (2 targets) now exhausts both stalled targets and resolves with"All targets failed"instead of a direct stall error message.