#973·gun

Relay peer crash breaks all browser clients until they refresh the page

Author: JoncomCreated Jun 25, 2020Updated Jun 17, 2025

TL;DR: 2 clients connect to a relay peer. They subscribe to data using gun.on(), and everything works fine. However, if the relay peer crashes and comes back, clients do not resume receiving updates and must refresh the page to resolve the issue.

Chat from Discord:

Joncom:

  1. ClientA and ClientB are both connected to PeerServer1, the only peer server.
  2. Both clients are listening to changes on object foo like so: let callback = function(data) { console.log(data); }; gun.get('foo').on(callback);
  3. PeerServer1 goes offline, and clients cannot communicate
  4. ClientA writes some offline data to foo like so: gun.get('foo').put({a: 1});
  5. callback fires on ClientA because subscribed to foo
  6. ClientB writes some offline data to foo like so: gun.get('foo').put({b: 1});
  7. callback fires on ClientB because subscribed to foo
  8. PeerServer1 comes back online and both peers connect to it

Question: Should callback fire again on ClientA as it receives the offline update put by ClientB, and vice versa?

I would expect the data from ClientA to sync over to ClientB (and vice versa) and trigger the on callback to fire, when the clients reconnect to the peer server. However, in practice, despite reconnecting to the peer server, clients don't receive updates from each other, and a refresh is needed before all updates show up on both clients. :(

Mark Nadal:

Yes Your 1 ~ 8 is exactly what the PANIC holy-grail test does/checks, yes you should get called with those offline updates. If you're having to refresh, then this is a regression/bug.

Steps to reproduce:

  1. Clone Gun repo
  2. cd test/panic/
  3. mocha holy-grail.js
  4. The test will not complete (hangs on "Browsers re-initialized gun!")