Repository navigation
The bridges connect again when their connection to the mind ends - #3
Merged
Merged
Conversation
A session's sign-in lasts 4 hours. The live bridge and the device-events bridge connected once, so after 4 hours the Mac heard no watcher and its presence events were lost. Both now hold their connection through `bridge/mind-connection.mjs`: it notices a closed or failed connection, connects again with the stored sign-in after 1 s, doubling to 60 s, and runs each bridge's setup again (the live bridge subscribes again and asks for the ICE servers again; it checks once a minute that its subscription still hears). Events wait during a gap and go up in order; after a reconnect the app publishes the present presence again. `live.state().signalling` says whether the signalling is connected. CI runs the bridges' new tests. Session: claude b0eec5e0-9c0a-43e6-bf1b-01b7e83c523c on jonas-macbook-pro Co-Authored-By: Claude Opus 5.5 <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.
The bridges connect again when their connection to the mind ends
What.
bridge/mind-connection.mjsis a connection that lasts: it waits on the connection's ownclosed(and on calls that fail with a closed connection), connects again after 1 s, twice as long each failure, at most 60 s, and runs a callback on each new connection.device-live.mjssubscribes again and fetches the ICE servers again on each connection, and checks once a minute that its subscription still hears (an ephemeraldevice/live-pingonly it consumes).device-events.mjskeeps events while the connection is down (at most 2,000; moves and keys go first), retries a batch that failed, and sends in order after the reconnect; the app then publishes its presence again.live.state().signallingnow says whether the signalling is connected. 12node --testtests with a fake mind, now in CI.Why. A session's sign-in lasts 4 hours; then the mind closes the socket with 1008. The live and events bridges connected once, so after that every call failed: "Watch live" stayed at "asking the device…", and presence changes were lost. A live subscription also ended once on the mind's side with no word to the bridge.
Proof. Against a live mind, on a test device: the live bridge heard a watcher's signal again after a 1008 close, after a terminated socket, and after its subscription row was removed on the mind (found by the ping); the events bridge sent 6 of 6 events in order across a 1008 close, 2 of them queued while it was down. Tests:
node --test 'bridge/*.test.mjs'(12),swift build,swift test.Risk map.
realpath(argv[1])against the module's path).🤖 Generated with Claude Code
Session: claude b0eec5e0-9c0a-43e6-bf1b-01b7e83c523c on jonas-macbook-pro
🤖 Generated with Claude Code