diff options
| author | Adam Soltys <[email protected]> | 2026-09-05 21:47:30 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-09-05 21:47:30 -0700 |
| commit | 7e96dc4d4292b29156ec6b9b9c7009f8c60106f1 (patch) | |
| tree | 5705b219a401bd419f523078d1c937ff0134425b /nwcpush | |
| parent | ec1d6b8c6da0f9e4e169f4e8f95b88133207b741 (diff) | |
| download | coinosv3-7e96dc4d4292b29156ec6b9b9c7009f8c60106f1.tar.gz coinosv3-7e96dc4d4292b29156ec6b9b9c7009f8c60106f1.zip | |
Heal dead push subscriptions from a VAPID key rotation — the reason notifications went silent. registerPush reused whatever getSubscription() returned and only ever subscribed fresh when there was none; a subscription made against an OLD VAPID key can never receive a push (the notifier's send fails with a permanent 403, which was never pruned, and the client kept re-registering the same dead endpoint). Now the client fetches the current VAPID key first and, when an existing subscription's applicationServerKey doesn't match, unsubscribes and re-subscribes against the current key — so a device self-heals on next open. And the notifier prunes 403 endpoints alongside 404/410. Deployed nwcpush on cs
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MGzU12QrAA4G6BYGzGVdXz
Diffstat (limited to 'nwcpush')
| -rw-r--r-- | nwcpush/server.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/nwcpush/server.js b/nwcpush/server.js index 61cab60..cd7d28f 100644 --- a/nwcpush/server.js +++ b/nwcpush/server.js @@ -169,11 +169,14 @@ async function pushNotify(id, r, reason, extra) { } log(`notify(${reason}) -> device ${id}`); } catch (e) { - if (e.statusCode === 404 || e.statusCode === 410) { + // 404/410 = gone; 403 = the sub was made against a different VAPID key + // and can NEVER receive a push (a stale key rotation), so prune it too — + // the client re-subscribes fresh against the current key on next open. + if (e.statusCode === 404 || e.statusCode === 410 || e.statusCode === 403) { delete notifyRegs[id]; persist(); resubscribeNotify(); - log(`dropped an expired notify endpoint ${id}`); + log(`dropped a dead notify endpoint ${id} (${e.statusCode})`); } else { log(`notify(${reason}) push failed for ${id}: ${e.statusCode || e.message}`); } |
