Repository navigation
fix(rtc): mark room queue task done on publish and unpublish track errors - #902
Open
NabiBukhsh-AI wants to merge 1 commit into
Open
NabiBukhsh-AI wants to merge 1 commit into
NabiBukhsh-AI wants to merge 1 commit into
Conversation
In LocalParticipant.publish_track and LocalParticipant.unpublish_track, queue.task_done() was placed at the bottom of the try: block, after checking for FFI errors. If an error occurred or an exception was raised, queue.task_done() was skipped during active subscription. Move queue.task_done() immediately after await queue.wait_for(...) in both methods, satisfying Queue.wait_for's contract and unblocking Room._listen_task's queue join immediately upon event receipt.
NabiBukhsh-AI
requested review from
changt,
cloudwebrtc,
lukasIO and
xianshijing-lk
as code owners
October 26, 2026 07:33
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
LocalParticipant.publish_trackandLocalParticipant.unpublish_track,queue.task_done()was placed at the end of thetry:block, after checking for FFI errors (if cb.publish_track.error:/if cb.unpublish_track.error:).When the FFI reports an error, the exception (
PublishTrackError/UnpublishTrackError) is raised beforequeue.task_done()is called. This leaves the room queue event unacknowledged during active subscription and keepsRoom._listen_task'sawait self._room_queue.join()waiting on that event until unsubscription teardown.This resolves the sibling bug to #565 (as noted by Devin review on #752) and ensures both methods adhere to
Queue.wait_for's contract (task_done must be manually called for the returned item).Changes
queue.task_done()immediately afterawait queue.wait_for(...)in bothLocalParticipant.publish_trackandLocalParticipant.unpublish_track.livekit-rtc/tests/test_publish_track_deadlock.pyverifying that:task_done()is invoked while the subscriber is still active when an FFI error occurs.Room._listen_task'sroom_queue.join()unblocks immediately upon error event receipt.Testing
pytest livekit-rtc/tests/test_publish_track_deadlock.py(all tests pass).ruff checkandruff format --check(passes).mypy(no type issues found).Closes #565