Skip to content

fix(mobile): stop calling removed identity clear_badges route on foreground - #14644

Merged
dylanjeffers merged 1 commit into
mainfrom
fix/mobile-json-parse-html
Oct 8, 2026
Merged

dylanjeffers merged 1 commit into
mainfrom
fix/mobile-json-parse-html

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

Problem

Signed-in mobile builds log this every time the app comes to the foreground:

[SyntaxError: JSON Parse error: Unexpected character: <]

It shows up on Android 16 (RN 0.79.5), the 1.5.186 RC on a Saga (Android 14), and iOS 26.5 (RN 0.81.6, #14642), so it isn't tied to the RN version.

Cause

useResetNotificationBadgeCount runs on every foreground. It calls audiusBackend.clearNotificationBadges, which POSTs to identityservice.audius.co/notifications/clear_badges and then calls .json() on the response. #14207 removed that route from identity-service on 2026-04-30, so Express now returns its HTML 404 page:

$ curl -X POST https://identityservice.audius.co/notifications/clear_badges
<!DOCTYPE html> ... <pre>Cannot POST /notifications/clear_badges</pre>   -> 404 text/html

The catch passes the bare error to console.error, which produces the log line above.

Evidence

I foregrounded the signed-in iOS 26.5 release build on a simulator and read CFNetwork logs from the unified log:

22:28:43.627 [C530 ... url: https://identityservice.audius.co/notifications/clear_badges]
22:28:43.629 Task <4088> setting up Connection 530
22:28:43.793 Task <4088> received response, status 404
22:28:43.795 [com.facebook.react.log:javascript] [SyntaxError: JSON Parse error: Unexpected character: <]

Both earlier occurrences that session (17:17:04 and 17:18:05) were also a 404 from identity, 2 ms before the error. Each one came right after UIKit cleared the app's deactivation reasons. On iOS, useEnterForeground also fires on inactive -> active (Control Center, the notification shade, the app switcher), so the "about once a minute" pattern was how often the app was re-activated, not a timer. In the same session, a process that stayed in the foreground for 5 hours made no 404s and logged no errors.

clear_badges is the only identity route in AudiusBackend that no longer exists. I checked every other path it calls against identity-service/src/routes.

Fix

  • Remove the dead clear_badges request and audiusBackend.clearNotificationBadges. It had no other callers.
  • Keep clearing the local badge (PushNotifications.setBadgeCount(0)) on foreground.

The server-side PushNotificationBadgeCounts.iosBadgeCount is now reset to 0 by pedalboard's notification_seen listener (apps/notifications/src/notificationSeenListener.ts) when notifications are marked seen. This PR doesn't change server behaviour: the reset on app open has already been gone since #14207.

Testing

  • ESLint passes on the changed files. tsc shows no errors in the changed files.
  • I did not rebuild the app to watch the log line disappear. The request is removed outright, and the repro above was deterministic.

🤖 Generated with Claude Code

…ground

identity-service dropped /notifications/clear_badges in #14207. The mobile
foreground hook still POSTed to it and called .json() on Express's HTML 404,
logging "JSON Parse error: Unexpected character: <" on every foreground.

The server-side badge count is now reset by pedalboard's notification_seen
listener, so the client only needs to clear the local badge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 963a609

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dylanjeffers
dylanjeffers merged commit 2ddc1d2 into main Oct 8, 2026
18 checks passed
@dylanjeffers
dylanjeffers deleted the fix/mobile-json-parse-html branch October 8, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant