Skip to content

Conversation

@aleksandar-apostolov
Copy link
Collaborator

Goal

Fix and edge case where reconnect would need to happen after disconnect in the background while the initial connect is running.

Implementation

Correctly update the state in recoveryEffect in StreamClientImpl

Testing

Added two new unit tests for these scenarios.

Checklist

  • Issue linked (if any)
  • Tests/docs updated
  • I have signed the Stream CLA (required for external contributors)

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

Copy link
Contributor

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 fixes an edge case in the reconnection logic where the app backgrounds during an ongoing initial connect() call. The fix ensures that when a Recovery.Disconnect is triggered (e.g., when backgrounding), any in-flight connection attempt is properly canceled before disconnecting.

Key changes:

  • Enhanced recoveryEffect() to cancel pending connect operations when disconnecting
  • Reordered monitor startup to occur before token loading in connect()
  • Added comprehensive test coverage for background/foreground transitions during connection attempts

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
StreamClientImpl.kt Updated recoveryEffect() to cancel in-flight connects and properly update state; reordered network monitor startup
StreamClientIImplTest.kt Added three new tests and helper classes to verify reconnection edge cases during lifecycle transitions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 1, 2025

Copy link
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aleksandar-apostolov aleksandar-apostolov merged commit 76303c1 into develop Dec 1, 2025
12 checks passed
@aleksandar-apostolov aleksandar-apostolov deleted the edge-case-reconnect branch December 1, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants