From b3df6e629a8d165ac2d6f9fb6c4962d47da0f0cf Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 26 Sep 2026 22:51:52 -0700 Subject: Console: NWC chatter behind a debug switch; dead relays remembered longer and dropped from the pool. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `coinosDebug(true)` in the console (or ?debug=1) turns the nwc: listener logs back on; they are off by default. Warnings and errors stay. The red WebSocket lines were the pool's own reconnect loop redialling relays from other people's relay lists that have been dead for weeks — the sick list only stopped NEW dials, for ten minutes, and forgot on reload. A dead relay is now dropped from the pool (no reconnect loop), skipped twice as long each time it fails (up to a day), keyed by normalized URL, and the verdict survives a reload. A relay the pool has failed to reconnect to three times counts as dead. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01VhUKyXKtsJ67QAFfb7QR9D --- src/debug.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/debug.js (limited to 'src/debug.js') diff --git a/src/debug.js b/src/debug.js new file mode 100644 index 0000000..5d7d085 --- /dev/null +++ b/src/debug.js @@ -0,0 +1,17 @@ +// A console kept quiet by default. The chatter that helps when something is +// being chased (the NWC listener's generations, relay health) goes through +// dlog and shows only once debugging is switched on — from the console with +// `coinosDebug(true)`, or by opening the app with `?debug=1`. `coinosDebug(false)` +// turns it off again. Warnings and errors that mean something is wrong are +// not gated; they stay on console.warn / console.error. +const KEY = 'coinos-debug'; +export const debugOn = () => { try { return localStorage.getItem(KEY) === '1'; } catch { return false; } }; +export const dlog = (...a) => { if (debugOn()) console.log(...a); }; +if (typeof window !== 'undefined') { + window.coinosDebug = (on = true) => { + try { localStorage.setItem(KEY, on ? '1' : '0'); } catch {} + console.log('coinos debug ' + (on ? 'on' : 'off')); + return on; + }; + try { if (new URLSearchParams(location.search).get('debug') === '1') localStorage.setItem(KEY, '1'); } catch {} +} -- cgit v1.2.3