From 59d0991115465106d960d1983fdd1b7c94aef7e6 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 3 Aug 2026 08:05:16 -0700 Subject: Fix the service-worker ReferenceError; stop dialing dead relays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sw.js threw "NWC_WAKE_FALLBACK is not defined" on every load: the template substitution used String.replace with a string pattern, which replaces only the FIRST match — and that was the mention inside the comment above, leaving the real placeholder literal in the output (parsed as a block plus a bare identifier). replaceAll fixes it, the comment no longer spells the token, and {{VERSION}} got the same treatment. Both build profiles now emit a service worker that parses and activates cleanly. The relay noise: a browser logs failed WebSocket connections itself and JS cannot suppress that line, so the fix is to stop making the doomed connection. nostr.js now probes each new relay once, remembers unreachable ones for ten minutes, and filters them out of every subscribe/query/publish (never down to an empty set). Publish rejections that look like connection failures mark the relay sick rather than logging a scary "refused" line. relay.damus.io — down all week — also leaves the profile relay list. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01Wvj4aoeMZwA7VUGdJP9Swi --- build.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'build.js') diff --git a/build.js b/build.js index 3e42930..fde56b5 100644 --- a/build.js +++ b/build.js @@ -58,7 +58,7 @@ self.addEventListener('activate', (e) => { // NWC push handling lives in src/sw-nwc.js (bundled and appended below when // the nwc+ark features ship): it tries to ANSWER the request from the pouch -// and falls back to a notification. {{NWC_WAKE_FALLBACK}} carries a +// and falls back to a notification. The placeholder below carries a // notify-only handler for builds without those features. {{NWC_WAKE_FALLBACK}} @@ -259,8 +259,8 @@ if (import.meta.main) { const feats = enabledFeatures(); const nwcSw = feats.includes('nwc') && feats.includes('ark'); const swBody = SW - .replace('{{VERSION}}', version) - .replace('{{NWC_WAKE_FALLBACK}}', nwcSw ? '' : SW_WAKE_ONLY); + .replaceAll('{{VERSION}}', version) + .replaceAll('{{NWC_WAKE_FALLBACK}}', nwcSw ? '' : SW_WAKE_ONLY); await Bun.write('dist/sw.js', nwcSw ? swBody + '\n' + await buildSwNwc() : swBody); for (const f of STATIC) await Bun.write('dist/' + f, Bun.file('static/' + f)); // default avatars, self-hosted since coinos.io's copies are half-broken -- cgit v1.2.3