avoid KeyError when track is already unpublished#743
Conversation
| elif which == "track_subscribed": | ||
| owned_track_info = event.track_subscribed.track | ||
| track_info = owned_track_info.info |
There was a problem hiding this comment.
🚩 Other remote-track event handlers still use hard dictionary lookups and may crash under the same race conditions
This PR defensively handles the case where track_unpublished arrives after the participant or publication has already been removed. However, the same race condition (participant disconnected before event is processed) could affect track_unsubscribed (room.py:857-858), track_subscribed (room.py:843-844), track_subscription_failed (room.py:867-868), track_muted (room.py:879), and track_unmuted (room.py:890), all of which still use hard [] lookups on self._remote_participants and track_publications. If the fix here is warranted, the same defensive pattern may be needed in those handlers to avoid KeyError crashes in _listen_task.
(Refers to lines 840-865)
Was this helpful? React with 👍 or 👎 to provide feedback.
fixes #4639