-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: sync state with disconnected peers (take 2) #891
Conversation
/** | ||
* @param {PeerId} peerId | ||
*/ | ||
#getOrCreatePeerState(peerId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of this method was misleading, and its use in #onPeerRemove was causing a bug, because it was recreating a removed state.
/** | ||
* @param {string} peerId | ||
*/ | ||
disconnectPeer(peerId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: should this be called removePeer()
to match addPeer()
? Same comment applies elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it because there is a removePeer
in CoreSyncState which means something different.
There are two scenarios where a disconnected peer results in sync never showing as complete.
Scenario A:
Scenario B:
Note that these bugs affect
project.$sync.waitForSync()
, which I don't think the front-end is not currently using. The mechanism used for determining if sync is completed in the front-end may still work.Fix
This PR fixes what appears to be an oversight for what happens when a peer disconnects (e.g. turns wifi off or force-closes app). We were removing the
PeerSyncController
, but we were not removing the remote state fromCoreSyncState
. I think I had some confusion about whether we should keep remote states for disconnected peers. For now, this PR "fixes" this to just completely remove remote states for disconnected peers. If we think keeping the remote state for disconnected peers in the future is useful, we can add it at a later stage. Right now, the remote state for a disconnected peer is just a cause of bugs, so not useful.