diff options
| author | Adam Soltys <[email protected]> | 2026-08-03 08:05:16 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-08-03 08:05:16 -0700 |
| commit | 59d0991115465106d960d1983fdd1b7c94aef7e6 (patch) | |
| tree | def53fccb7235fb6d7c92298b3a60424e5c2e38f /build.js | |
| parent | 86101d5ff381ca9832a4e4c17c47d8350e2d12d0 (diff) | |
| download | coinosv3-59d0991115465106d960d1983fdd1b7c94aef7e6.tar.gz coinosv3-59d0991115465106d960d1983fdd1b7c94aef7e6.zip | |
Fix the service-worker ReferenceError; stop dialing dead relays
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wvj4aoeMZwA7VUGdJP9Swi
Diffstat (limited to 'build.js')
| -rw-r--r-- | build.js | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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 |
