Repository navigation
Description
Context
The pushsubscriptionchange listener ignores event.newSubscription. It returns unless event.oldSubscription.options.applicationServerKey exists, then subscribes again with that key and POSTs the result to /api/push/subscribe (packages/ui-sdk/src/client/push-handlers.ts:114-135).
Chrome for Android 138 and Samsung Internet 30 fire this event with the browser-renewed subscription in newSubscription (MDN BCD 8.1.6: PushSubscriptionChangeEvent.newSubscription and oldSubscription in Chrome for Android 138, Samsung Internet 30, Firefox for Android 137; earlier Firefox fired the event without either property). When the browser has already renewed the endpoint, calling pushManager.subscribe() again is redundant at best; when oldSubscription is null, the new endpoint is never reported and notifications stop until the app is opened and the toggle or login rebind heals it.
The module comment (push-handlers.ts:15-20) describes only the resubscribe path.
Guide: (no guide).
Binding: Action notifications and the wire contract ("The SDK registerPushHandlers renewal now sends the worker's zone"), which stays true. The POST body keeps its shape { subscription, timeZone? }. docs/decisions/http-api-boundary.md:67 cites push-handlers.ts:72; a PR that moves that line updates the citation.
Scope
- If
event.newSubscriptionis present, POST it (withreportedTimeZone()) tosubscribeUrland do not callpushManager.subscribe(). - Otherwise, if
oldSubscription.options.applicationServerKeyis present, keep today's resubscribe-and-POST. - Otherwise do nothing and leave repair to the next app open.
- Wrap whichever path runs in
event.waitUntil, and keep the existing catch-all for offline or logged-out failures. - Update the module comment to describe the three cases.
Out of scope
- Deleting the old endpoint on the server (the sender already prunes on 404/410,
packages/ui-server/src/activity/push-sender.ts:248). - Server-side changes to
/api/push/subscribe. notificationclick(ui-sdk: a notification tap loses its deep link when the app window is not controlled #2567) and notification options (ui-sdk: push notifications show a generic Android status-bar icon instead of the brand badge #2570).- The client-side rebind in
ui-react(ui-react: the push toggle keeps reading on after notifications are revoked in Android settings #2571).
Acceptance criteria
- With
newSubscriptionpresent, exactly one POST is made with{ subscription: newSubscription, timeZone }, andpushManager.subscribeis not called. - With only
oldSubscriptioncarrying a key, behaviour is unchanged: subscribe with that key, then POST. - With neither, no request is made and no
waitUntilis registered. - A rejected POST or subscribe does not reject the
waitUntilpromise. - Tests in
packages/ui-sdk/tests/push-handlers.test.tsdrive the registered listener through a structural scope and a stubbedfetch(restored in teardown); thenewSubscription-only case fails on the tree before the change. - Firefox for Android before 137 (event without properties) does nothing, as today.
- No browser test is required: no automation API can fire
pushsubscriptionchangeon a real worker. The PR states this.
Verification
bun run test packages/ui-sdk/tests/push-handlers.test.ts
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
Not contract: the renewal request and its body are unchanged; only which subscription it carries changes.
Activity