Skip to content

Mobile app fetches the Expo push token from exp.host twice on every resume #8224

Description

@lanjak

Summary

Each time the bb mobile app comes back to the foreground, it runs two push registration syncs, and each sync POSTs to https://exp.host/--/api/v2/push/getExpoPushToken before it finds that the registration is up to date. The Expo push token does not change between resumes, so both requests are redundant. Expected: no token request on a resume when the device token has not changed.

Versions and environment

  • bb from source at origin/main 2a21dd56f69cb1b72d78f97d51e8d4d72f09fe2e (apps/mobile, expo-notifications 58.1.8).
  • Linux, Node v26.13.1 (measured with Vitest and the real createPushRegistrationController; no device needed).

Steps to reproduce

  1. Turn on notifications for a server in the mobile app, so the server has a registration.
  2. Put the app in the background and bring it back.
  3. Count requests to exp.host (for example with a proxy), or run the controller with fake modules as below.

Controller reproduction: create createPushRegistrationController with a fake PushNotificationsModule that counts getExpoPushToken calls and a fake PushSubscriptionsApi that counts register calls. Sync once (cold start), then repeat the host's resume pattern 10 times: refreshPermission().then(() => sync(profile)) (AppState active) together with sync(profile) (the effect that runs again when realtime reconnects).

Expected vs actual

Actual at 2a21dd56f6:

cold start (connected effect): token fetches=1 registers=1
10 resumes (AppState active + reconnect effect): token fetches=20 registers=0
device token roll: token fetches=2 registers=0

Expected: 0 token fetches on resume, and 1 fetch after a device token roll.

Evidence

  • Two syncs per resume: the AppState active handler and the effect that depends on connected both call controller.sync (PushNotificationsHost.tsx#L117-L131).
  • Each sync fetches the Expo push token first and only then compares it with the stored record (push-registration.ts#L140-L160).
  • The fetch is Notifications.getExpoPushTokenAsync (expo-push-module.ts#L70-L74). In expo-notifications 58.1.8 (src/getExpoPushTokenAsync.ts) this always POSTs to exp.host, and then turns on the library's automatic server registration. From then on, src/DevicePushTokenAutoRegistration.fx.ts sends every device token change to Expo by itself, and checks the last uploaded device token at each app start.
  • Device token changes already reach the controller through addTokenListener and handleTokenRolled (push-registration-controller.ts#L177-L185), and a 24 h re-registration exists (PUSH_REGISTRATION_REFRESH_MS).

What you ruled out

AGENT GENERATED

Activity

  1. added theissue type on Nov 26, 2026
  2. added
    mobile
    remote
    confirmed-repro
    on Nov 26, 2026
  3. bb-slop-cop commented on Nov 26, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Low · areas: mobile, remote; perf.
    • Report: Reproduction and root cause.
    • Verdict: REPRODUCED · Confidence: high · Label: confirmed-repro.
    • Root cause: Each reconciliation resolves the Expo token before checking registration freshness; overlapping foreground/reconnect triggers also schedule a trailing reconciliation.
    • Evidence: An authored controller regression fails identically in two clean checkouts of trusted main (b0ddaad731): three simulated resumes make six token requests and zero server-registration writes. All 29 relevant existing tests pass. Actual device traffic was not captured.
    • No new PR: #8225 already links this issue, so another fix would duplicate it. Its code was not executed.
  4. added a commit that references this issue on Nov 30, 2026
    a4a4d5c
  5. added a commit that references this issue on Dec 1, 2026
    269cd36
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

    confirmed-repromobileperfremote

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions