diff options
| author | Adam Soltys <[email protected]> | 2026-07-30 19:47:00 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-07-30 19:47:00 -0700 |
| commit | c21685559ee814e95cb37a5660c73762a8db12c9 (patch) | |
| tree | 3cb190c87374d2214f474cca71b18fdfc2484b50 /lib | |
| parent | 1d48335f47bbb673b89b42a9ef2984eaae7b02d2 (diff) | |
| download | coinos-server-c21685559ee814e95cb37a5660c73762a8db12c9.tar.gz coinos-server-c21685559ee814e95cb37a5660c73762a8db12c9.zip | |
nwc: guard missing app record in the notification loop
A pubkey can be in `${uid}:apps` before its `app:<pubkey>` 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 <[email protected]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/notifications.ts | 9 |
1 files changed, 7 insertions, 2 deletions
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:<pubkey>` 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 = { |
