From c21685559ee814e95cb37a5660c73762a8db12c9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 30 Jul 2026 19:47:00 -0700 Subject: nwc: guard missing app record in the notification loop A pubkey can be in `${uid}:apps` before its `app:` record is written (NWC-connection creation race) or can outlive its record. Destructuring `notify` off the null lookup threw, and since the catch wraps the whole loop it aborted notifications for ALL of the user's apps. Skip null/absent apps and continue. Co-Authored-By: Claude Opus 4.8 --- lib/notifications.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/notifications.ts b/lib/notifications.ts index 09f4fb2b..3fa880c4 100644 --- a/lib/notifications.ts +++ b/lib/notifications.ts @@ -94,8 +94,13 @@ export const nwcNotify = async (p) => { } catch (e) {} } for (const pubkey of pubkeys) { - const { notify } = await g(`app:${pubkey}`); - if (!notify) continue; + // The app record may be missing/not-yet-written: a pubkey lands in + // `${uid}:apps` before its `app:` is persisted (creation race when + // adding an NWC connection), or a stale entry outlived its record. Guard + // the lookup — destructuring `notify` off null threw and, since the catch + // wraps the whole loop, aborted notifications for ALL the user's apps. + const app = await g(`app:${pubkey}`); + if (!app?.notify) continue; l("notifying", pubkey, p.type, p.amount); const notification = { -- cgit v1.2.3