fix(mobile): probe socket liveness on resume instead of trusting session state - #4963
Open
Theremoteaidoc wants to merge 1 commit into
Open
fix(mobile): probe socket liveness on resume instead of trusting session state#4963Theremoteaidoc wants to merge 1 commit into
Theremoteaidoc wants to merge 1 commit into
Conversation
…ion state When the app resumes within the background grace window, onAppResumed trusted state.status == connected and returned early. But the transport can be half-open after even a brief background stint: iOS drops the network on screen lock or rebinds NAT on a Wi-Fi/cellular switch, and no close frame ever reaches the client. The session is then a zombie - live subscriptions stay silent and the UI never updates until the user force-kills the app. Replace flag-trust with a cheap liveness probe on the early-return path: a minimal REQ that resolves on EOSE (3s timeout, injectable for tests). On timeout or error, reconnect - which already replays live subscriptions with the since-skew. Repro on device: open a channel on iOS, background the app briefly (or lock the screen), have another client post to the channel, resume: the message never renders; force-kill + reopen shows it. With the probe, the dead transport is detected on resume and the reconnect replay delivers the missed events. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0167FGVQ3hiePvK6V32HioqZ
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.
Fixes #4962
Problem
onAppResumedtrustsstate.status == SessionStatus.connectedwhen the background stint was shorter than the grace window. After an iOS suspend the transport can be half-open (screen lock drops the network, NAT rebinds on interface switch; the frozen VM never ran the grace-disconnect timer and no close frame arrives), so the app resumes onto a zombie socket: live subscriptions are silent until the user force-kills the app.Fix
On the early-return path, run a cheap liveness probe: a minimal
REQ(kinds[39000], limit 1) that resolves onEOSE, with a 3s timeout (constructor-injectable for tests). On timeout or error,reconnect()— the existing replay-with-since-skew then delivers everything missed. A healthy socket answers EOSE in one round-trip and nothing else changes.Tests
Two new cases alongside the existing resume tests, using a send-recording controlled socket:
connected(preserves the existing short-background behavior);reconnecting).Authored with Claude Code on a self-hosted Buzz deployment where our operator hit this daily on iPhone; happy to adjust probe kind/timeout to maintainer preference.
🤖 Generated with Claude Code
https://claude.ai/code/session_0167FGVQ3hiePvK6V32HioqZ