Record subscription intent and reconcile until converged - #947
Draft
milos-lk wants to merge 2 commits into
Draft
Conversation
UpdateSubscription signal messages are fire-and-forget: SetSubscribed sends one message and keeps no record of it. If that message is lost (stalled controller, dropped relay stream, reconnect race), desired and actual subscription state diverge permanently - the SDK waits forever and sync state on resume only replays subscriptions that already attached. - record desired subscription state per track in SetSubscribed - reconcile loop per room re-sends UpdateSubscription (batched, with backoff) until the subscription attaches or is cleared; started lazily on the first recorded desire so rooms that never subscribe selectively never spawn it, stopped on room cleanup - unsubscribes have no client-side convergence observable (the attached track is never cleared), so they are re-asserted a bounded number of times per connection epoch instead of reconciled to convergence - sendSyncState replays recorded intent, not just attached tracks - reconcile kicked (and attempt counters reset) after resume and full reconnect - handle SubscriptionResponse errors: stop re-asserting rejected subscriptions and fire OnTrackSubscriptionFailed instead of timing out; routed via a new optional SubscriptionResponseProcessor interface so existing SignalProcessor implementations keep compiling Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
boks1971
approved these changes
Jul 7, 2026
| } else { | ||
| unsubscribe[pub.participantID] = append(unsubscribe[pub.participantID], sid) | ||
| } | ||
| r.log.Infow( |
Contributor
There was a problem hiding this comment.
maybe log this outside the loops?
Recording before sending leaked the transient desire to a concurrently running reconcile pass or sync state during the send window, so a call that returned an error could still cause an UpdateSubscription to go out, and rolling back by re-setting the previous desire reset its retry backoff and started the reconciler even for failed calls. Recording after the send succeeds makes the error path a true no-op. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
UpdateSubscription signal messages are fire-and-forget: SetSubscribed sends one message and keeps no record of it. If that message is lost (stalled controller, dropped relay stream, reconnect race), desired and actual subscription state diverge permanently - the SDK waits forever and sync state on resume only replays subscriptions that already attached.
No breaking API changes