Repository navigation
fix(rtc): mark room queue task done on publish and unpublish track errors - #902
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.
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)
|
Hi @cloudwebrtc @lukasIO, Gentle check-in on this PR. It ensures All CI tests are passing. Ready for review whenever you have a chance! |
|
Thanks for the detailed write-up and tests! Closing this since the behavior is already handled on I ran the new tests locally to confirm:
|
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