Skip to content

fix(transcription): end a stream cleanly when the provider already closed it - #356

Merged
AnkushMalaker merged 1 commit into
devfrom
fix/stt-closed-stream
Nov 16, 2026
Merged

AnkushMalaker merged 1 commit into
devfrom
fix/stt-closed-stream

Conversation

@thestumonkey

Copy link
Copy Markdown
Contributor

Problem

Deepgram closes an idle stream (NET-0001) after about 10 s with no audio. When the session then ended, end_stream sent CloseStream on the dead socket. It raised ConnectionClosedError, logged a traceback, marked transcription completion as error, and never removed the stream from _streams (one leaked entry per such session).

No transcript is lost: finals that arrived before the close were already published.

Fix

  • end_stream pops the stream entry first, so no exit path leaks it.
  • An already-closed socket logs one warning with the close code and reason, then returns an empty final result.

Not in scope

  • Sending Deepgram KeepAlive during audio pauses, so the stream stays open. Not done on purpose.

Tests

  • tests/test_streaming_end_stream_closed.py: fails before the fix (2 failed), passes after, on upstream dev.
  • tests/test_streaming_clock_offset.py: passes (10 passed together).

🤖 Generated with Claude Code

…osed it

Deepgram closes an idle stream (NET-0001) after ~10 s without audio. When
the session then ended, end_stream sent CloseStream on the dead socket,
raised ConnectionClosedError, and never removed the stream entry. It now
unregisters the stream first and logs one warning for an already-closed
socket instead of raising.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a4759813-db56-4cc2-90b1-df01f45eebc6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@AnkushMalaker
AnkushMalaker merged commit 408c584 into dev Nov 16, 2026
5 of 9 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.

2 participants