fix(elevenlabs): re-arm response timeout after audio arrives - #7627
Merged
Merged
Conversation
The audio handler cancelled the per-context timeout timer but left `ctx.timeout_timer` set, so `_start_timeout_timer` never armed a new one on later sends. A provider stall after the first audio chunk waited forever. Reset the handle to None in both the TTS and text-to-dialogue connections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After the last send, audio cancelled the timer and nothing re-armed it, so a provider that stalled before its final message left the stream waiting forever. Arm the timer when close_context is sent and re-arm it on each audio chunk after that. Before close, the timer is still armed only by sends, so slow LLM input does not time out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
_Connectionand_DialogueConnectionreceive loops cancelctx.timeout_timerwhen audio arrives, but they do not reset it toNone._start_timeout_timerreturns early whenctx.timeout_timeris set, so later sends never arm a new timer. If the provider stalls after the first audio chunk, the stream waits forever instead of raisingAPITimeoutError.ctx.timeout_timer = Noneaftercancel()in both receive loops.Testing
test_recv_loop_resets_timeout_timer_on_audio, parametrized over both connection classes. It fails without the fix and passes with it.ruff format --check,ruff check,mypypass on the changed files.test_prewarm_stops_on_non_retryable_api_errorfails onmaintoo; it is not related to this change.