Description
Found bug in gun.js that can be found today at https://cdn.jsdelivr.net/npm/gun/gun.js
In function reconnect(peer) , after line 1777 ( clearTimeout(peer.defer); ) I added a single line
console.log("I'm in reconnect, opt=",opt);
After 1 reconnect attempt you fill find the opt variable empty {} so the reconnect function will NEVER be called again because of the next line:
if(!opt.peers[peer.url]){ return }
So I just comment out that line and everything is OK!
Test procedure AFTER operating my hack:
- check if super-peer is up and running
- run a simple Gun app in 2 browsers, A and B , check app if working and get updates each other
- stop the super-peer server
- your app in A and B servers are running, updating their own local storage, reconnect is called at 2 seconds for many times
- after 30 seconds or more, start super-peer again
- your app in A and B browser are reconnecting just fine, everything is ok
Your app document updates during network failure simulation ARE saved in local storage of browsers, they are NOT automatically pushed to other peers or super-peer upon reconnection but I'm feeling that it's not possible, yet! Anyway, I found a "TODO: resync upon reconnect online/offline" at line 1734 and I suppose that it might be possible sometime?
Anyway, updates during offline time are delivered to other peers from local storage WHEN REQUESTED by other peers, so it's not a show-stopper, probably apps should be designed with periodically auto-refresh.
Best regards,
Teo