Log push send failures instead of swallowing them silently

sendPush caught every webpush.sendNotification error to clean up
expired subscriptions, but never logged anything for other failure
modes — made a delivery problem indistinguishable from 'nothing to
send' when debugging.
This commit is contained in:
Duarte Santos committed 2026-07-21 11:42:40 +02:00
1 parent 17cad3fa3a
commit 7dea9ccfcc
1 file changed
+1
+1
View File
@@ -58,6 +58,7 @@ async function sendPush(userId, payload) {
await Promise.all(subs.map(async sub => {
try { await webpush.sendNotification({ endpoint: sub.endpoint, keys: sub.keys }, body); }
catch (e) {
console.error('push send failed', userId, e.statusCode, e.body || e.message);
if (e.statusCode === 404 || e.statusCode === 410) {
db.subs = db.subs.filter(s => s.endpoint !== sub.endpoint); dirty = true;
}