fix(session): retry on 5xx errors from non-standard provider error types#19204
fix(session): retry on 5xx errors from non-standard provider error types#19204okuyam2y wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PRsFound 2 related PRs that address similar retry logic issues:
These PRs are not exact duplicates but address the same general area (session/retry error handling for provider responses). You may want to review them for potential conflicts or ensure consistency in the retry logic approach. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
…ypes Some API gateways throw non-APICallError errors with status codes in varying shapes (error.status, error.statusCode, error.response.status, or JSON-encoded in error.message). These were not being detected, causing 5xx errors to be classified as UnknownError instead of retryable APIError. Add ErrorWithStatus interface and multi-path status code extraction to the Error case in fromError(), with JSON message fallback.
4be2e20 to
dbb61ba
Compare
|
Rebased onto latest dev and squashed into a single commit. All 28 Changes from previous version:
Would appreciate a review when you get a chance. Happy to address any feedback. |
Issue for this PR
Closes #19203
Type of change
What does this PR do?
MessageV2.fromErroronly upgradesAPICallErrorinstances to retryableAPIError. When an OpenAI-compatible provider throws a plainErroror object with HTTP status fields instead, the error falls through toNamedError.Unknownand session retry never runs.This adds a fallback status extractor for non-
APICallErrorinputs and classifies 5xx responses as retryableAPIError. Covered shapes: top-levelstatus/statusCode, nestedresponse.status/response.statusCode, JSON-encoded error messages carrying those fields (with inner message extraction), and plain objects with the same properties.A file-local
ErrorWithStatusinterface is used instead ofas anycasts, following the existingFetchDecompressionErrorpattern. 4xx handling is unchanged.How did you verify your code works?
message-v2.test.tscovering all extraction paths and negative cases (4xx, no status)message-v2tests and 19retrytests passbun typecheckpasses across all packagesChecklist