Skip to content

fix(elevenlabs): re-arm response timeout after audio arrives - #7627

Merged
davidzhao merged 2 commits into
mainfrom
fix/elevenlabs-timeout-rearm
Oct 4, 2026
Merged

davidzhao merged 2 commits into
mainfrom
fix/elevenlabs-timeout-rearm

Conversation

@davidzhao

@davidzhao davidzhao commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Summary

  • The _Connection and _DialogueConnection receive loops cancel ctx.timeout_timer when audio arrives, but they do not reset it to None.
  • _start_timeout_timer returns early when ctx.timeout_timer is set, so later sends never arm a new timer. If the provider stalls after the first audio chunk, the stream waits forever instead of raising APITimeoutError.
  • Fix: set ctx.timeout_timer = None after cancel() in both receive loops.

Testing

  • Added 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, mypy pass on the changed files.
  • test_prewarm_stops_on_non_retryable_api_error fails on main too; it is not related to this change.

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>
@davidzhao
davidzhao requested a review from a team as a code owner October 4, 2026 21:58
devin-ai-integration[bot]

This comment was marked as resolved.

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>

@chenghao-mou chenghao-mou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@davidzhao
davidzhao merged commit a7c62e3 into main Oct 4, 2026
25 checks passed
@davidzhao
davidzhao deleted the fix/elevenlabs-timeout-rearm branch October 4, 2026 22:22
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.

2 participants