Skip to content

fix(azure): recover from STT error cancellations instead of hanging#6362

Merged
longcw merged 1 commit into
livekit:mainfrom
apoorva-01:fix/azure-stt-error-cancellation
Jul 9, 2026
Merged

fix(azure): recover from STT error cancellations instead of hanging#6362
longcw merged 1 commit into
livekit:mainfrom
apoorva-01:fix/azure-stt-error-cancellation

Conversation

@apoorva-01

@apoorva-01 apoorva-01 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

If Azure STT hits an error cancellation (like a service timeout), the stream just goes silent. _on_canceled only logged a warning, and Azure doesn't reliably send session_stopped after that, so _run blocks on its asyncio.wait forever. Audio keeps flowing into a dead recognizer and nothing raises, so retry and fallback never kick in.

Now an error cancel records the details and sets the stopped event, so _run wakes and raises APIConnectionError. The base retry loop and FallbackAdapter handle it from there.

I kept it on the base retry path instead of adding retry inside the plugin like the earlier attempt (#5333). Happy to flip it if you'd rather.

Tests in tests/test_plugin_azure_stt.py cover both cases.

Fixes #5322

Azure doesn't always send session_stopped after an error cancel, so the run loop could hang. Wake it and raise so the base retry/fallback takes over.
@apoorva-01 apoorva-01 requested a review from a team as a code owner July 9, 2026 07:37

@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 potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@longcw longcw 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.

thanks for the pr! looks good to me

@longcw longcw merged commit 43c1654 into livekit:main Jul 9, 2026
17 checks passed
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.

Azure STT plugin does not handle timeout error properly

2 participants