Skip to content

fix(workers-ai-provider): normalize retryable binding errors - #656

Open
fenil010 wants to merge 1 commit into
cloudflare:mainfrom
fenil010:fix/retryable-binding-errors
Open

fix(workers-ai-provider): normalize retryable binding errors#656
fenil010 wants to merge 1 commit into
cloudflare:mainfrom
fenil010:fix/retryable-binding-errors

Conversation

@fenil010

@fenil010 fenil010 commented Sep 9, 2026

Copy link
Copy Markdown

Summary

Fixes an issue where retryable errors thrown directly by the Workers AI AI.run() binding were propagated as plain Error objects instead of being normalized to APICallError.

This prevented the AI SDK from recognizing retryable: true binding errors and automatically retrying failed requests.

Root Cause

The workers-ai-provider transport: "run" path calls AI.run() directly. Errors thrown by the binding bypassed normalizeBindingError(), so the AI SDK could not detect their retryability.

Changes

  • Normalize errors thrown by AI.run() at the transport boundary.
  • Add explicit retryable flag detection in gateway-core.
  • Preserve retryable: true and retryable: false when creating APICallError.
  • Give explicit retryability precedence over Workers AI error-code classification.
  • Preserve existing AbortError and APICallError handling.
  • Keep unclassified errors non-retryable.
  • Add regression tests for retry behavior, cancellation, error metadata, and custom OpenAI Responses transport recovery.
  • Add a changeset for workers-ai-provider.

Testing

  • 22 test files passed
  • 471 tests passed
  • Package build passed
  • oxlint: 0 errors
  • Formatting/linting checks passed

No custom retry loop was introduced; the fix uses the AI SDK's existing retry mechanism once the binding error is correctly classified.

Closes #654

@changeset-bot

changeset-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 826152d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
workers-ai-provider Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

Workers AI Responses delegate does not normalize binding errors carrying retryable: true

1 participant