Replace SfuConnectException with SfuConnectFailureCause code#1744
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
WalkthroughSFU connection failures now carry typed causes for observation timeouts, recoverable socket failures, and terminal socket failures. ChangesSFU failure classification and recovery
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Call._join
participant RtcSession.connectInternal
participant reconnect
Call._join->>RtcSession.connectInternal: connect to SFU
RtcSession.connectInternal-->>Call._join: SfuConnectionResult.Failure(cause)
Call._join->>reconnect: start REJOIN for observation timeout
reconnect-->>Call._join: recovery outcome
Call._join-->>Call._join: fail immediately for terminal failure
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…eator with Call..unitTestRtcSessionFactory
|
f9369e3
into
fix/sfu-join-self-triggered-reconnect
…1741) * fix(core): recover initial join when connect safety-timeout leaves no reconnect When RtcSession.connectInternal hits its own safety-timeout, the socket is left in a non-terminal state that stateJob ignores, so no Call.reconnect is ever launched and _join's didReconnectSucceed() would block forever. - Add SfuConnectionResult.Failure.reconnectTriggered so the join flow can tell whether a recovery loop has already been started by stateJob. - On the safety-timeout path, tear down the abandoned (still-in-flight) socket so a late Connected/JoinResponse can't resurface and resurrect the session. - In Call._join, trigger a REJOIN ourselves when a recoverable failure reports no reconnect was triggered; otherwise await the existing loop. - Rename canTriggersReconnect() to triggersStateJobReconnect() for clarity. - demo-app: align connectionTimeoutInMs with the SDK default (5s). Co-authored-by: Cursor <cursoragent@cursor.com> * refactor(core): type SFU connect failures instead of a reconnect flag Address PR review: reconnect-orchestration state should not live on the SfuConnectionResult.Failure DTO. Replace the boolean flag with a typed error so callers of connectInternal branch on the failure kind. - Add sealed SfuConnectException with Timeout (connect safety-timeout tore down a stuck socket; no recovery started) and Disconnected (terminal SFU state). - connectInternal now returns these typed errors instead of Exception("msg"). - Drop SfuConnectionResult.Failure.hasReconnectStarted; _join self-triggers a REJOIN only when the error is SfuConnectException.Timeout, else awaits the loop stateJob already started. - Update tests to construct/assert the typed errors. Co-authored-by: Cursor <cursoragent@cursor.com> * Replace SfuConnectException with SfuConnectFailureCause code (#1744) * fix: Refactor with SfuConnectFailureCause code * fix: Add kdoc * fix: Replace Singletone shared Call.testInstanceProvider.rtcSessionCreator with Call..unitTestRtcSessionFactory --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Aleksandar Apostolov <apostolov.alexandar@gmail.com> Co-authored-by: Rahul Kumar Lohra <tgunix@gmail.com>


Goal
Refactor SFU connect failure classification to use domain-level failure causes instead of exception subclasses.
AN-1294
The implementation on PR: Recover initial join when connect safety-timeout leaves no reconnect
uses
SfuConnectException.TimeoutandSfuConnectException.Disconnectedto tell_join()how to handle a failed SFU connect attempt. That works mechanically, but the model is misleading:Timeoutis not a network-layer exception here; it meansconnectInternal()gave up waiting for the socket to reach a terminal state.Disconnectedis an SFU socket state, not an exception._join()is really branching on domain failure causes, not exception types.Implementation
Replace
SfuConnectExceptionwith:Refactor SfuConnectionResult.Failure
Before
After
🎨 UI Changes
None
Testing
Not required, this is a code refactor on WIP PR
Summary by CodeRabbit