Skip to content

fix(voice): finish background audio cleanup when the room disconnects - #7228

Open
kiwijuicer wants to merge 1 commit into
livekit:mainfrom
kiwijuicer:norbert/fix-background-audio-disconnect
Open

fix(voice): finish background audio cleanup when the room disconnects#7228
kiwijuicer wants to merge 1 commit into
livekit:mainfrom
kiwijuicer:norbert/fix-background-audio-disconnect

Conversation

@kiwijuicer

Copy link
Copy Markdown

BackgroundAudioPlayer.aclose() can wait indefinitely for unpublish_track() when the room has already disconnected or disconnects before the acknowledgement arrives. This can hold up agent shutdown after a call ends.

Race unpublishing against the room's disconnected event, skip the request when already disconnected, and remove the listener and settle the owned task on every exit. Connected rooms still wait for the acknowledgement; existing exception suppression and caller cancellation behavior are preserved.

Regression coverage exercises normal acknowledgement, both disconnect orderings, cancellation, and an unpublish error. The two disconnect cases fail on unmodified upstream and all five pass with this fix. make check passes.

@kiwijuicer
kiwijuicer requested a review from a team as a code owner September 11, 2026 13: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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant