Skip to content

ui-sdk: a push subscription the browser renews is never sent to the server #2568

Open

Description

@schlessera

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.newSubscription is present, POST it (with reportedTimeZone()) to subscribeUrl and do not call pushManager.subscribe().
  • Otherwise, if oldSubscription.options.applicationServerKey is 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

Acceptance criteria

  • With newSubscription present, exactly one POST is made with { subscription: newSubscription, timeZone }, and pushManager.subscribe is not called.
  • With only oldSubscription carrying a key, behaviour is unchanged: subscribe with that key, then POST.
  • With neither, no request is made and no waitUntil is registered.
  • A rejected POST or subscribe does not reject the waitUntil promise.
  • Tests in packages/ui-sdk/tests/push-handlers.test.ts drive the registered listener through a structural scope and a stubbed fetch (restored in teardown); the newSubscription-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 pushsubscriptionchange on a real worker. The PR states this.

Verification

bun run test packages/ui-sdk/tests/push-handlers.test.ts
bun run typecheck
bun run lint

Contract impact

  • This touches the integration contract, so it needs the contract label, a CONTRACT: 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

  1. added
    type: fix
    area: ui-sdk
    priority: p2
    agent-ready
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-sdkpriority: p2type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions