Skip to content

fix: sync call state after a failed reconnect #1846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2025

Conversation

oliverlaz
Copy link
Member

💡 Overview

When a call reconnect fails because of unrecoverable error (typically due to a permission revocation, or call being ended in the meantime), the client-side call state wasn't up-to-date with the server-side one (/join didn't return any data).

📝 Implementation notes

In this PR, before flagging the callingState as RECONNECTING_FAILED, we perform an additional request to our backend so we can synchronize both states.

🎫 Ticket: https://linear.app/stream/issue/RN-241/refresh-call-state-after-a-failed-reconnect

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures client and server call states stay in sync by fetching the latest call data before marking a reconnect as failed.

  • Introduces a markAsReconnectingFailed helper that calls this.get() then updates the calling state
  • Replaces direct setCallingState(RECONNECTING_FAILED) calls in reconnect failure paths with await markAsReconnectingFailed()
Comments suppressed due to low confidence (1)

packages/client/src/Call.ts:1361

  • Consider adding unit tests to verify that when reconnect fails (e.g., due to an unrecoverable error), get() is called and the calling state transitions to RECONNECTING_FAILED as expected.
      const markAsReconnectingFailed = async () => {

@oliverlaz oliverlaz merged commit 905e5c2 into main Jul 7, 2025
17 of 18 checks passed
@oliverlaz oliverlaz deleted the fetch-latest-call-state branch July 7, 2025 12:49
oliverlaz added a commit that referenced this pull request Jul 8, 2025
Follow-up to #1846. `call.leave()` throws an error after unrecoverable FAST reconnect.
Our "leave" flow requires the client to announce its disconnect from the
call to the SFU so the SFU can perform certain state cleanups faster.
However, in the case described above, this isn't possible because the
new SFU client never successfully connected to the SFU, and the signal
WS was never established. This makes it impossible to send the announcement.

This PR adds better error handling and doesn't prevent the `call` instance disposal.

🎫 Ticket:
https://linear.app/stream/issue/RN-241/refresh-call-state-after-a-failed-reconnect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants