emit peer-synchronize when a peer's synchronize message is processed#847
Open
gmaclennan wants to merge 1 commit into
Open
emit peer-synchronize when a peer's synchronize message is processed#847gmaclennan wants to merge 1 commit into
peer-synchronize when a peer's synchronize message is processed#847gmaclennan wants to merge 1 commit into
Conversation
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.
peer-addis emitted before a peer has sent anything, so there is currently no way to observe when a peer's remote state (peer.remoteLength,peer.remoteFork,peer.remoteSynced) becomes known or changes.This PR emits a
peer-synchronizesession event, mirroringpeer-add/peer-remove, after a synchronize message has updated the peer's remote state fields. The emission is placed before thecloseIfIdle()early-return so it also fires for sessions that immediately idle-close.The first emission for a peer marks the completion of its handshake.
No behavior change; observability only.
Use case: CoMapeo tracks per-peer replication state (sync progress across a set of devices) and needs to know when a peer's length handshake has completed. We've previously been using
core.update({ wait: true })for this, which is wrong because it resolves immediately for writable cores, resolves for all waiters when any peer supplies an upgrade, and samples at mostMAX_PEERS_UPGRADEpeers.