repairChecker: Yjs is now able to detect incorrect states that happen when messages get lost. When Yjs is in an incorrect state it repairs itself and syncs again

This commit is contained in:
Kevin Jahns
2016-09-27 16:12:35 +02:00
parent f0e88d192c
commit 17803266d4
3 changed files with 50 additions and 1 deletions

View File

@@ -66,6 +66,16 @@ module.exports = function (Y/* :any */) {
this.whenSyncedListeners = []
return this.y.db.stopGarbageCollector()
}
repair () {
console.info('Repairing the state of Yjs. This can happen if messages get lost, and Yjs detects that something is wrong. If this happens often, please report an issue here: https://github.com/y-js/yjs/issues')
for (var name in this.connections) {
this.connections[name].isSynced = false
}
this.isSynced = false
this.currentSyncTarget = null
this.broadcastedHB = false
this.findNextSyncTarget()
}
setUserId (userId) {
if (this.userId == null) {
this.userId = userId