Repository navigation
fix: xAI streaming transcription connect failure errors the stream - #310
Closed
cunninghamcard-bit wants to merge 2 commits into
Closed
cunninghamcard-bit wants to merge 2 commits into
cunninghamcard-bit wants to merge 2 commits into
Conversation
@ai-sdk/xai 5.0.12 opens the STT WebSocket inside the returned stream (xai-transcription-model.ts:276-358), so doStream resolves and a connect failure errors the stream, cancelling the caller's audio. aimux connected before returning and failed do_stream itself. The connect now runs first inside the stream; on failure the stream yields the error and ends, which drops the audio. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
This was referenced Oct 20, 2026
Upstream's ReadableStream start runs when doStream builds the stream, so the WebSocket is opened before doStream resolves even if the stream is never read. Connecting on the stream's first poll would skip the connection for a stream dropped unread; connect in do_stream instead and hand the outcome to the stream, which still yields a failure as its error. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5
This was referenced Oct 20, 2026
Contributor
Author
|
Folded into #311 together with the other xAI fixes, so each vendor has one fix PR. This change is commits Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Before: xAI streaming transcription opened its WebSocket in
do_streamand returned a connect failure (a refused connection, a failing custom connector) as theErrofdo_streamitself.After: as in
@ai-sdk/xai5.0.12,do_streamstill opens the socket before it returns (upstream'sReadableStreamstartruns while doStream builds the stream), but a connect failure no longer failsdo_stream: the returned stream yields it as its only item and ends, which drops the caller's audio stream (upstream cancels it).Found while porting the upstream xAI tests (case
doStream › should cancel the audio stream when the WebSocket constructor throws). Part of the #276 list.How it works today
What this PR changes
The socket is still opened before
do_streamreturns, so a stream dropped unread has connected, as upstream's has (its caseshould strip undefined header values before the WebSocket constructorreads the handshake after cancelling the unread stream).Tests (
tests/xai_transcription_test.rs):a_connect_failure_errors_the_streampoints the model at a closed port and expectsdo_streamto resolve and the stream to hold one error; it fails on master withdo_stream resolves; the connect failure arrives on the stream: ApiCall(... "websocket connect failed: ... Connection refused"). The upstream case is ported in the xAI test PR.Docs: CHANGELOG
Fixed.Type of change
Checklist
cargo +1.99 fmt -p aimux-providers -- --checkpassescargo +1.99 clippy -p aimux-providers --lib --tests -- -D warningspassescargo +1.99 test -p aimux-providers --test xai_transcription_testpasses (19)scripts/check_provider_boundaries.shpassesNotes for reviewers
Only xAI changes here. ElevenLabs streaming transcription also returns a connect failure from
do_stream(elevenlabs.rs:941); it is not touched, since its upstream package is ported separately.🤖 Generated with Claude Code
https://claude.ai/code/session_01RoxcKU4zBD64Lri3e4Lrq5