Skip to content

fix(google): don't let closing the TTS input generator mask the real error - #7041

Open
avionicharshit-byte wants to merge 1 commit into
livekit:mainfrom
avionicharshit-byte:fix/google-tts-input-gen-aclose-race
Open

fix(google): don't let closing the TTS input generator mask the real error#7041
avionicharshit-byte wants to merge 1 commit into
livekit:mainfrom
avionicharshit-byte:fix/google-tts-input-gen-aclose-race

Conversation

@avionicharshit-byte

Copy link
Copy Markdown

SynthesizeStream._run_stream hands input_gen to the grpc client, which drives it from its own task. when the call fails, that task is usually still parked inside the generator waiting for the next sentence, so the await input_gen.aclose() in the finally raises

RuntimeError: aclose(): asynchronous generator is already running

and that replaces the APITimeoutError / APIStatusError the caller was meant to see. it shows up on interrupted turns and on deadline exceeded, so it reads as intermittent.

same race and same fix as #4766, which guarded the aclose() calls in utils/aio/itertools.py.

added tests/test_plugin_google_tts_stream_close.py: a fake client consumes input_gen from a background task, then raises DeadlineExceeded. it fails on main with the RuntimeError and passes with the guard.

@CLAassistant

CLAassistant commented Aug 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@avionicharshit-byte
avionicharshit-byte marked this pull request as ready for review August 29, 2026 18:13
@avionicharshit-byte
avionicharshit-byte requested a review from a team as a code owner August 29, 2026 18:13

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants