You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 45165e2
Browse filesBrowse the repository at this point in the historyBrowse files
fix(retry): address deferred review feedback on provider retry PR
Three follow-up fixes for items the original PR explicitly deferred to a
later patch:
1. Provider ID normalization mismatch (provider-retry.ts)
Registration used `key.trim()` only; runtime lookups used `model.provider`
in canonical form (lowercased + alias-mapped). Provider configs keyed by
"OpenAI", "z.ai", "modelstudio", etc. silently failed to match runtime
lookups. Fix: route both register and lookup through normalizeProviderId
so they're symmetric. Tests cover case, alias, and whitespace variants.
2. Retry-After header parsing (retry-policy.ts)
getProviderApiRetryAfterMs assumed err.headers is a plain object and used
bracket access. fetch `Headers` instances only expose `.get()` —
bracket access returns undefined, silently dropping the server's hint.
Fix: probe both shapes; for plain objects also try Title-Case variants
(HTTP header names are case-insensitive, Headers.get handles that
internally). Tests cover plain-bag (lowercase + Title-Case) and Headers.
3. Abort-signal-aware backoff (retry.ts + retry-policy.ts + 3 transport sites)
Plain setTimeout-based sleep ignored the request's AbortSignal; cancelling
a request would still wait up to one full backoff interval (max 30s) before
the retry loop exited. Fix:
- Added `signal?: AbortSignal` to RetryOptions; abortableSleep() rejects
promptly on abort, retry loop catches and stops without throwing the
abort itself (rethrows the most recent attempt's error so the caller
can distinguish API failure from cancel by checking signal.aborted).
- Also check signal.aborted at top of each loop iteration so we don't
start a new attempt for an already-cancelled request.
- RetryRunner now accepts an optional `{ signal }` options object as a
third arg; backwards-compatible with the existing `(fn, label)` form.
- Three call sites in openai-transport-stream.ts updated to pass
`{ signal: options?.signal }`.
Tests: backoff is interrupted within ~50ms of abort even with 5s minDelay;
no new attempt is started when signal aborts during the first attempt.
All 51 retry-related tests pass; tsc --noEmit clean.
0 commit comments