diff options
| author | Adam Soltys <[email protected]> | 2026-08-01 17:44:38 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-01 17:44:38 -0700 |
| commit | a64611377c646415bc0c21a8bb96b9a079c4ce2b (patch) | |
| tree | 3a91beb8e96f6ba20dbadc05210b12b5f46d1223 /src/features | |
| parent | 46cbe94159fe65d8cb6a944b52a9ead6c53e7a3c (diff) | |
| download | coinosv3-a64611377c646415bc0c21a8bb96b9a079c4ce2b.tar.gz coinosv3-a64611377c646415bc0c21a8bb96b9a079c4ce2b.zip | |
Add an NWC subscription watchdog
The pool's reconnect doesn't heal every socket death (an errored socket
sets skipReconnection and gives up), and a wallet service with a dead
subscription looks exactly like one that's closed — the client spins
with no error, which is what happened to tonight's zaps. Re-subscribe
every 90s and on online/visibility transitions; the since window plus
the replay guard make the churn and any duplicate deliveries harmless.
Co-Authored-By: Claude Fable 5 <[email protected]>
Diffstat (limited to 'src/features')
| -rw-r--r-- | src/features/nwc.js | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/features/nwc.js b/src/features/nwc.js index 20b0dd3..a4fcc03 100644 --- a/src/features/nwc.js +++ b/src/features/nwc.js @@ -463,6 +463,24 @@ export function nwcFeature(ctx) { }); } + // Watchdog: relay sockets can die in ways the pool's reconnect never heals + // (an errored socket sets skipReconnection and gives up), and a wallet + // service with a dead subscription is indistinguishable from one that's + // closed — clients just spin. Re-subscribing is cheap and duplicate + // deliveries are absorbed by the replay guard, so re-listen on a timer and + // whenever the network or the tab comes back. + let watchdog = null; + function startWatchdog() { + if (watchdog) return; + watchdog = setInterval(() => { if (conns().length) listen(); }, 90 * 1000); + if (typeof window !== 'undefined') { + window.addEventListener('online', () => listen()); + document.addEventListener('visibilitychange', () => { + if (document.visibilityState === 'visible' && conns().length) listen(); + }); + } + } + // ---- UI --------------------------------------------------------------- function nwcCard() { @@ -538,8 +556,8 @@ export function nwcFeature(ctx) { return { id: 'nwc', - init() { listen(); }, - stop() { stop(); }, + init() { listen(); startWatchdog(); }, + stop() { stop(); if (watchdog) { clearInterval(watchdog); watchdog = null; } }, settingsCards() { return [nwcCard()]; }, }; } |
