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:
1 parent
17cad3fa3a
commit
7dea9ccfcc
1 file changed
+1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user