amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
17.93k stars 1.16k forks source link

put events while offline never get synced #1378

Open eyaler opened 2 weeks ago

eyaler commented 2 weeks ago

Code to recreate - based on basic/note example:

const peers = ['https://gun-manhattan.herokuapp.com/gun', 'https://try.axe.eco/gun', 'https://test.era.eco/gun']
const gun = Gun(peers)
const pad = gun.get(location.hash.slice(1) || 'default')
addEventListener('online', () => {gun.opt(peers); pad.get('heartbeat').put('heartbeat')})
textarea.addEventListener('input', () => pad.put({content: textarea.value}))
pad.on(data => textarea.value = data.content)

The line with the online event reconnects the gun and the heartbeat allows the reconnected client to receive the missed "on" events.

However, the put events that happened in the offline client never get synced (even if these were the only events in the network). In this state the graphs are not consistent, and I could not find a way to explicitly check the sync status/diff or force the sync in this direction.