Skip to content

Conversation

@mikehardy
Copy link
Collaborator

@mikehardy mikehardy commented Nov 26, 2025

Description

@sean5940 noticed a few issues with our remote message storage implementation while collaborating on the related PR

They are serious enough I'd like to get fixes for them out as soon as possible, independent of the work on that PR

There are 5 tiny commits here so that the problems were hopefully immediately obvious and the fixes are hopefully obviously correct

First two are just refactors for clarity.
The last three are the fixes

  • actually remove the message from SharedPreferences instead of just pretending to 🤦
  • when purging the store down to limit, purge it all the way, not assuming only one removal is sufficient
  • purge the store down to the limit - 1 so there is room for new message before adding new message

Related issues

Release Summary

two refactor commits / three fix commits, it will generate a fix release

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

Hoping for @sean5940 to try these with the patch-package set that the PR run generates to see what he thinks, or you could pull the branch directly?


Think react-native-firebase is great? Please consider supporting the project with any of the below:

@vercel
Copy link

vercel bot commented Nov 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-native-firebase Ready Ready Preview Comment Nov 26, 2025 1:54am

it was duplicated, which means any fixes have to be in multiple spots
previously the remove was not applied, so it likely never persisted to
storage, leading to infinite growth and possible OOM
previously, stored messages were cleared one at a time each time a message
came in, opening the possibility that the store would contain more messages
then the limit and never get back down to the limit.

now it will attempt to shrink down to the limit every time a message comes in
ensuring that if there is an over limit condition it will be fixed quickly
previously we added before purging, so if close to an OOM we would trigger it,
if an app update is pushed with this change, it will ideally recover completely
from this situation by purging the store down before any new data is added
@mikehardy mikehardy force-pushed the @mikehardy/properly-remove-android-messages branch from 9f556ae to 7e8975e Compare November 26, 2025 01:50
@mikehardy mikehardy added platform: android plugin: messaging FCM only - ( messaging() ) - do not use for Notifications Workflow: Needs Review Pending feedback or review from a maintainer. impact: crash Behaviour causing app to crash. Priority: P1 labels Nov 26, 2025
preferences.setStringValue(S_KEY_ALL_NOTIFICATION_IDS, notificationIds);

// check and remove old notifications message
// remove old notifications message before store to free space as needed
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the diff for the 5th commit is easier to understand in split view, it's mostly code motion swapping the two chunks of logic, not code change

Copy link

@sean5940 sean5940 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

This PR provides a necessary and correct fix for the recurring OOM risk caused by uncontrolled remote message storage in SharedPreferences.

@mikehardy mikehardy merged commit 47ea774 into main Nov 27, 2025
29 of 40 checks passed
@mikehardy mikehardy deleted the @mikehardy/properly-remove-android-messages branch November 27, 2025 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact: crash Behaviour causing app to crash. platform: android plugin: messaging FCM only - ( messaging() ) - do not use for Notifications Priority: P1 Workflow: Needs Review Pending feedback or review from a maintainer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants