Skip to content

Backport: fix(gateway): enable retry support for gateway errors#15220

Merged
aayush-kapoor merged 1 commit into
release-v6.0from
backport-pr-15213-to-release-v6.0
May 12, 2026
Merged

Backport: fix(gateway): enable retry support for gateway errors#15220
aayush-kapoor merged 1 commit into
release-v6.0from
backport-pr-15213-to-release-v6.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

This is an automated backport of #15213 to the release-v6.0 branch. FYI @aayush-kapoor

## Background

#14216 

Gateway errors (GatewayInternalServerError, GatewayRateLimitError,
GatewayTimeoutError) were never retried by `maxRetries` because
`asGatewayError()` converts the original APICallError into a
GatewayError subclass before the retry logic sees it. The retry function
only checked APICallError.isInstance(error), which always returned false
for Gateway errors

## Summary

- Add `isRetryable` to `GatewayError` base class, derived from
`statusCode` using the same logic as `APICallError` (408, 409, 429, >=
500)
- Extend `_retryWithExponentialBackoff` to also check
`GatewayError.isInstance(error) && error.isRetryable`
- For retry-after header extraction, unwrap `error.cause` when the error
is a `GatewayError` with an `APICallError` cause

## Manual Verification

na

## Checklist

- [x] All commits are signed (PRs with unsigned commits cannot be
merged)
- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)

## Related Issues

fixes #14216

Co-authored-by: Pini Shvartsman
<7192105+PiniShv@users.noreply.github.com>
@github-actions github-actions Bot enabled auto-merge (squash) May 12, 2026 19:19
auto-merge was automatically disabled May 12, 2026 19:25

Pull request was closed

@aayush-kapoor aayush-kapoor reopened this May 12, 2026
@aayush-kapoor aayush-kapoor enabled auto-merge (squash) May 12, 2026 19:26
@aayush-kapoor aayush-kapoor merged commit 253bd5a into release-v6.0 May 12, 2026
17 checks passed
@aayush-kapoor aayush-kapoor deleted the backport-pr-15213-to-release-v6.0 branch May 12, 2026 19:41
@github-actions
Copy link
Copy Markdown
Contributor Author

🚀 Published in:

Package Version
ai 6.0.180
@ai-sdk/angular 2.0.181
@ai-sdk/gateway 3.0.114
@ai-sdk/google 3.0.73
@ai-sdk/google-vertex 4.0.128
@ai-sdk/langchain 2.0.186
@ai-sdk/llamaindex 2.0.180
@ai-sdk/react 3.0.182
@ai-sdk/rsc 2.0.180
@ai-sdk/svelte 4.0.180
@ai-sdk/vue 3.0.180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant