From 8fdea8305b699f3b255fd1674ffd0aeb0933715f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 1 Aug 2026 13:51:56 -0700 Subject: Keep relay sockets alive: enable pool ping + auto-reconnect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A silently dropped WebSocket (proxy idle timeout, network change) used to kill every live subscription with nothing re-subscribing — device sync stopped merging and the NWC service stopped answering until the next reload. That is how a connection created on the phone stayed invisible to an open laptop tab. The pool now pings every 29s (dummy-REQ fallback in browsers) and reconnects with backoff, re-firing open subscriptions from the last event seen. Co-Authored-By: Claude Fable 5 --- src/nostr.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nostr.js b/src/nostr.js index 006a74c..2c458af 100644 --- a/src/nostr.js +++ b/src/nostr.js @@ -21,7 +21,11 @@ import { base64urlnopad } from '@scure/base'; // One shared pool for all relay I/O — it manages connection lifecycles (and the // CLOSE-after-EOSE handshake) cleanly, so we never send on a half-closed socket. -const pool = new SimplePool(); +// Ping + reconnect matter: without them a quietly dropped socket (proxy idle +// timeout, network blip) takes every live subscription with it and nothing +// re-subscribes — sync stops merging and NWC stops answering until a reload. +// On reconnect the pool re-fires open subs with since = last event seen. +const pool = new SimplePool({ enablePing: true, enableReconnect: true }); // Subscribe / publish on an explicit relay set, independent of the sync // feature's configuration. NWC needs this: the relays it advertises in a -- cgit v1.2.3