aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-01 13:51:56 -0700
committerAdam Soltys <[email protected]>2026-08-01 13:51:56 -0700
commit8fdea8305b699f3b255fd1674ffd0aeb0933715f (patch)
treed1ae3860b83f3e45fbb206e8312f0d3a3e02e2c0 /src
parentef7f5aa8d713bf0e754607f9fcc0527c5a10e737 (diff)
downloadcoinosv3-8fdea8305b699f3b255fd1674ffd0aeb0933715f.tar.gz
coinosv3-8fdea8305b699f3b255fd1674ffd0aeb0933715f.zip
Keep relay sockets alive: enable pool ping + auto-reconnect
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/nostr.js6
1 files changed, 5 insertions, 1 deletions
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