Repository navigation
fix(elevenlabs): propagate non-retryable STT errors instead of swallowing them - #7978
Closed
Speedyzyzz wants to merge 3 commits into
Closed
Speedyzyzz wants to merge 3 commits into
Speedyzyzz wants to merge 3 commits into
Conversation
…wing them When the ElevenLabs WebSocket STT server sends a quota_exceeded or auth_error frame, the previous except Exception handler in _recv_task silently swallowed the error and left the WebSocket in a half-open receive loop that hung indefinitely — producing a zombie agent session with no audio output and no visible error. Two changes to close this: 1. Re-raise APIError before the generic except Exception handler so that any APIError (including the APIConnectionError raised by _handle_error) escapes _recv_task and is seen by the caller rather than being logged and suppressed. 2. Mark quota_exceeded and auth_error as non-retryable (retryable=False) in _handle_error. Previously every _handle_error path raised APIConnectionError() without a retryable flag, which defaults to True, causing the reconnect loop to keep retrying a credential or quota failure that will never recover. Together these ensure a fatal server error cleanly terminates the stream instead of spinning forever. Tests: added test_recv_task_propagates_api_error_on_error_message in tests/test_plugin_elevenlabs_stt.py, which feeds a quota_exceeded frame into a live SpeechStream and asserts that APIConnectionError is raised within 1 s. 109/109 tests pass, ruff clean.
Contributor
|
fixed by #7287 |
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.
Problem
When the ElevenLabs STT WebSocket server sends a
quota_exceededorauth_errorframe, the existingexcept Exceptionhandler in_recv_tasksilently swallowed the error. This left the WebSocket stuck in a half-open receive loop that hung indefinitely — producing a zombie agent session with no audio output, no transcript events, and no visible error surfaced to the caller.Two root causes combine to produce the hang:
APIErrorswallowed byexcept Exception:_handle_errorraisesAPIConnectionError(a subclass ofAPIError), but the outerexcept Exceptionin_recv_taskcatches and logs it instead of letting it escape. The task then blocks on the nextws.receive()call with no server message ever arriving.Non-retryable errors marked retryable:
_handle_errorpreviously raisedAPIConnectionError()without aretryableflag, which defaults toTrue. The reconnect loop therefore kept retryingquota_exceededandauth_errorfailures that can never recover without operator action.Fix
APIErrorbefore the genericexcept Exceptionhandler in_recv_task, so fatal server errors escape the task and are visible to the caller._handle_error, setretryable=Falseforquota_exceededandauth_errormessage types, andretryable=True(explicit) for all other server error frames.Tests
Added
test_recv_task_propagates_api_error_on_error_messageintests/test_plugin_elevenlabs_stt.py. The test feeds aquota_exceededframe into a liveSpeechStreamvia a stub WebSocket and asserts thatAPIConnectionErroris raised within 1 second rather than hanging.tests/test_plugin_elevenlabs_stt.pypass.ruff checkandruff formatare clean.