fix: prevent WebSocket reconnect race condition on app resume#35
Merged
wizzomafizzo merged 2 commits intomainfrom Feb 4, 2026
Merged
fix: prevent WebSocket reconnect race condition on app resume#35wizzomafizzo merged 2 commits intomainfrom
wizzomafizzo merged 2 commits intomainfrom
Conversation
Track the 500ms setTimeout in immediateReconnect() so subsequent calls cancel any pending timer. This fixes a race condition when both app resume and network status change trigger immediateReconnect() in quick succession, which could leave the connection stuck in "reconnecting" state. Also clear the timer in pauseHeartbeat() to prevent connections from opening while the app is in the background.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Verify that: - Multiple rapid immediateReconnect() calls don't create multiple connection attempts (second call cancels first timer) - pauseHeartbeat() cancels any pending immediate reconnect to prevent connections opening while the app is backgrounded
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.
Summary
immediateReconnect()so subsequent calls cancel any pending timerpauseHeartbeat()to prevent connections opening while backgroundedcleanup()for thorough resource cleanupFixes intermittent issue where the app gets stuck in "reconnecting" state after resuming from background.