Skip to content

fix(client): avoid SFU socket close when online fires without offline recovery#2292

Merged
jdimovska merged 1 commit into
mainfrom
offline-recovery
Jun 18, 2026
Merged

fix(client): avoid SFU socket close when online fires without offline recovery#2292
jdimovska merged 1 commit into
mainfrom
offline-recovery

Conversation

@jdimovska

@jdimovska jdimovska commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

💡 Overview

This PR fixes an issue where a network: online event could close the SFU WebSocket even though the call had not entered offline recovery. This can happen when network: offline fires before the call has successfully joined, so no networkAvailableTask is created. When network: online later fires, the SDK should ignore it instead of closing the active SFU socket with 4100.

📝 Implementation notes

🎫 Ticket: https://linear.app/stream/issue/REACT-1014/network-change-closes-sfu-socket

📑 Docs: https://github.com/GetStream/docs-content/pull/

Summary by CodeRabbit

  • Bug Fixes
    • Improved network reconnection handling to prevent unnecessary operations when transitioning back online, ensuring more reliable connectivity restoration during network changes.

@changeset-bot

changeset-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 78f7935

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 277bddb6-4f96-4366-97e6-a2875d97211a

📥 Commits

Reviewing files that changed from the base of the PR and between a9c670d and 78f7935.

📒 Files selected for processing (1)
  • packages/client/src/Call.ts

📝 Walkthrough

Walkthrough

A single early-return guard is added in Call.registerReconnectHandlers inside the network.changed "going online" handler. When networkAvailableTask is not set, the handler now returns immediately, bypassing SFU socket teardown, waiter resolution, and SFU stats reporter restart.

Changes

Reconnect Handler Guard

Layer / File(s) Summary
Early-return guard in network.changed online path
packages/client/src/Call.ts
When networkAvailableTask is falsy on network-online transition, the handler returns early and skips closing the old SFU socket, resolving waiters, and restarting the stats reporter.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A rabbit hops back from offline land,
But finds no task waiting, as planned.
"Return early," it said with a grin,
No socket to close, no stats to begin.
One line of code, a neat little trick! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: preventing SFU socket closure when an online event fires without prior offline recovery being established.
Description check ✅ Passed The description follows the required template with Overview and Implementation notes sections, including ticket and docs links as specified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch offline-recovery

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jdimovska jdimovska requested a review from oliverlaz June 18, 2026 12:07
@jdimovska jdimovska merged commit 3034188 into main Jun 18, 2026
19 of 20 checks passed
@jdimovska jdimovska deleted the offline-recovery branch June 18, 2026 12:19
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.

2 participants