Skip to content

fix(workers-ai-provider): honor abort signals for binding streams - #641

Open
mikemikimike wants to merge 1 commit into
cloudflare:mainfrom
mikemikimike:fix/workers-ai-binding-abort
Open

fix(workers-ai-provider): honor abort signals for binding streams#641
mikemikimike wants to merge 1 commit into
cloudflare:mainfrom
mikemikimike:fix/workers-ai-binding-abort

Conversation

@mikemikimike

Copy link
Copy Markdown

Related issue

Fixes #640

Background

Workers AI binding streams can stall while a ReadableStreamDefaultReader.read() is pending. The provider forwarded the AI SDK abort signal to binding.run, but the stream-mapping pipeline did not observe it, so SDK timeouts and caller aborts could hang forever.

Changes

  • Race pending binding stream reads against the abort signal before SSE decoding.
  • Preserve signal.reason so TimeoutError and AbortError semantics remain intact.
  • Cancel the underlying reader when aborted and add a regression test for a stalled stream.
  • Added a patch changeset for workers-ai-provider.

Compatibility

Only binding-backed streaming responses are affected. Responses without an abort signal retain the existing behavior; normal stream completion and downstream cancellation remain supported.

Verification

  • git diff --check — passed.
  • pnpm install --frozen-lockfile — attempted, but npm registry downloads were too slow and the dependency installation did not complete.
  • Focused Vitest, type-check, and build — not run because installation did not finish and vitest was unavailable.

@changeset-bot

changeset-bot Bot commented Aug 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 80b6b46

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-provider: binding streams never honor abortSignal, so AI SDK timeout/abortSignal hang forever on stalled streams

1 participant