fix: WebSocket reconnection stability and manual pairing flow#2
Open
comlibmb wants to merge 3 commits into
Open
fix: WebSocket reconnection stability and manual pairing flow#2comlibmb wants to merge 3 commits into
comlibmb wants to merge 3 commits into
Conversation
- Add pollTunnelUrl (10s interval) to detect tunnel URL changes and auto-reconnect - Add AppState foreground handler to check URL changes and reconnect on app resume - Limit Socket.IO reconnection attempts to 3 to prevent conflicts with manual reconnect - Fix add-device.tsx: redirect "Enter Code" to device/pair.tsx (proven pairing flow) - Support ?method=code query param in pair.tsx to pre-select code entry mode - Remove competing checkTunnelUrlOnDisconnect to eliminate reconnection race conditions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When tunnel URL remains the same but connection drops, pollTunnelUrl now triggers a reconnect instead of only handling URL changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- pollTunnelUrl no longer does same-URL reconnect (prevents killing in-progress Socket.IO connections) - Socket.IO handles short-term reconnects (10 attempts, 2-30s backoff) - pollTunnelUrl only handles URL changes and fallback after Socket.IO gives up - Added _socketIoGaveUp flag to coordinate between Socket.IO and pollTunnelUrl - Foreground handler now retries 6 times with 5s intervals (30s total) - Removed dead code: checkTunnelUrlOnDisconnect, _tunnelCheckInProgress - Added RECONNECTION.md design document Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Fixes for WebSocket reconnection after tunnel restart and manual pairing code flow.
Changes
WebSocket Service (
services/websocket.service.ts)pollTunnelUrlpolls Supabase every 10s, detects tunnel URL change and auto-reconnectsApp Layout (
app/_layout.tsx)Add Device (
app/(onboarding)/add-device.tsx)device/pair.tsxfor reliable pairingPair Device (
app/device/pair.tsx)?method=codequery param to pre-select "Enter Code" modeBug Fixes
add-device.tsxshowed "Relay Address Required" dialog even in tunnel modeTest Plan