Files
livekit/pkg
Raja SubramanianandClaude Opus 5.5 46b81ee003 rtc: handle subscribed track close after subscription installation (#5265)
* rtc: handle subscribed track close after subscription installation

A close of a new SubscribedTrack during addSubscriber was lost or handled
too early. OnClose was registered before the track was stored and did not
replay an earlier close, and the publisher was marked after addSubscriber
returned. A close before the store left a closed track stored with no
resubscribe. A close after the store but before the mark left a stale
publisher mark.

SubscribedTrack now records a close and OnClose replays it. addSubscriber
marks the publisher itself and defers OnClose to its end, the same order
as the data track path.

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

* rtc: cover a rejected install and wait for the deferred close callback

TestSubscribeRevokedInFlight now waits for the close callback that
addSubscriber installs on return before it fires a close.
TestSubscribedTrackCloseDuringInstall adds a case where the recheck
rejects the install and the removal closes the track.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 21:42:58 +05:30
..