Skip to content

chore: revert react-native-mmkv to v3.x cp-7.78.0#30391

Merged
andrepimenta merged 4 commits into
mainfrom
chore/revert-mmkv-v4
May 20, 2026
Merged

chore: revert react-native-mmkv to v3.x cp-7.78.0#30391
andrepimenta merged 4 commits into
mainfrom
chore/revert-mmkv-v4

Conversation

@andrepimenta

@andrepimenta andrepimenta commented May 19, 2026

Copy link
Copy Markdown
Member

Revert the MMKV major bump that landed in #29195 (RN 0.81.5 upgrade). The v3 -> v4 jump was not required by RN 0.81 / React 19 / Expo SDK 54 and shipped a latent crash in migration 106 (PPOM cleanup) because v4 makes MMKV a type-only export while migration 106 was still calling new MMKV(...) against require('react-native-mmkv').MMKV.

CHANGELOG entry: null

Changes:

  • package.json: react-native-mmkv ^4.1.2 -> ^3.2.0 (resolves to 3.3.3) react-native-nitro-modules left pinned at 0.35.5 since react-native-vision-camera and other packages still need the new Nitro version.
  • app/store/storage-wrapper.ts: createMMKV() -> new MMKV(), .remove(key) -> .delete(key), drop the as MMKV cast, EventEmitter2 named import restored.
  • app/store/migrations/049.ts: factory -> constructor.
  • app/store/migrations/106.ts: drop the require + // eslint-disable workaround, use a plain import { MMKV }. Fixes the silent migration failure on devices that had PPOM storage.
  • app/store/migrations/136.ts: factory -> constructor, .remove() -> .delete() (this migration was added in feat: persist deeplink attribution with MMKV #29542 after the bump landed, so it needed forward-translation to v3 rather than a true revert).
  • app/store/migrations/106.test.ts, 136.test.ts: revert mock factory exports from createMMKV to MMKV.
  • app/util/notifications/settings/storage/index.ts: all three callsites swapped from createMMKV(...) to new MMKV(...).
  • app/util/test/testSetup.js, testSetupView.js: drop createMMKV from the module-level mock factory (v3 has no such export, so leaving it in would mask real production bugs in tests).
  • ios/Podfile.lock: regenerated. NitroMmkv pod + MMKVCore artifact removed; react-native-mmkv v3 pod added.

Verified post-revert: no createMMKV references left in the codebase, no import type { MMKV } left, no v4-style .remove(key) on MMKV instances, lints clean across all touched files. notificationStorage test still uses import { MMKV } for a type annotation, which works since v3 exports MMKV as a class (value + type).

TODO before merge: run the unit-test suite and an iOS/Android smoke build, plus the in-place upgrade canary scenario from #29195 to confirm v3 binaries can still read MMKV files that were written by v4 in any prior dev/internal build (production users are still on v3).

Description

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Reverts a major storage dependency version and updates MMKV instantiation/deletion APIs across migrations and wrappers, which can affect persistence and data cleanup behavior on upgrade. Risk is mitigated by targeted code changes and updated Jest mocks/tests, but should be validated with mobile smoke tests and migration paths.

Overview
Reverts react-native-mmkv from v4 to v3 (updates package.json, yarn.lock, and iOS pods) and removes the Nitro-related MMKV pods from Podfile.lock.

Updates all touched call sites to match the v3 API: replaces createMMKV(...) with new MMKV(...), switches key deletion from .remove(...) to .delete(...), and simplifies migration 106 to use a standard import { MMKV } (eliminating the prior require workaround).

Adjusts Jest mocks and migration tests (106, 136) to mock the MMKV constructor-only export expected in v3 and to assert .delete(...) behavior.

Reviewed by Cursor Bugbot for commit 042b30e. Bugbot is set up for automated code reviews on this repo. Configure here.

Revert the MMKV major bump that landed in #29195 (RN 0.81.5 upgrade). The
v3 -> v4 jump was not required by RN 0.81 / React 19 / Expo SDK 54 and
shipped a latent crash in migration 106 (PPOM cleanup) because v4 makes
`MMKV` a type-only export while migration 106 was still calling
`new MMKV(...)` against `require('react-native-mmkv').MMKV`.

Changes:

- package.json: `react-native-mmkv` ^4.1.2 -> ^3.2.0 (resolves to 3.3.3)
  `react-native-nitro-modules` left pinned at 0.35.5 since
  `react-native-vision-camera` and other packages still need the new
  Nitro version.
- app/store/storage-wrapper.ts: `createMMKV()` -> `new MMKV()`,
  `.remove(key)` -> `.delete(key)`, drop the `as MMKV` cast,
  `EventEmitter2` named import restored.
- app/store/migrations/049.ts: factory -> constructor.
- app/store/migrations/106.ts: drop the `require` + `// eslint-disable`
  workaround, use a plain `import { MMKV }`. Fixes the silent migration
  failure on devices that had PPOM storage.
- app/store/migrations/136.ts: factory -> constructor, `.remove()` -> `.delete()`
  (this migration was added in #29542 after the bump landed, so it
  needed forward-translation to v3 rather than a true revert).
- app/store/migrations/106.test.ts, 136.test.ts: revert mock factory
  exports from `createMMKV` to `MMKV`.
- app/util/notifications/settings/storage/index.ts: all three callsites
  swapped from `createMMKV(...)` to `new MMKV(...)`.
- app/util/test/testSetup.js, testSetupView.js: drop `createMMKV` from
  the module-level mock factory (v3 has no such export, so leaving it
  in would mask real production bugs in tests).
- ios/Podfile.lock: regenerated. NitroMmkv pod + MMKVCore artifact
  removed; react-native-mmkv v3 pod added.

Verified post-revert: no `createMMKV` references left in the codebase,
no `import type { MMKV }` left, no v4-style `.remove(key)` on MMKV
instances, lints clean across all touched files. `notificationStorage`
test still uses `import { MMKV }` for a type annotation, which works
since v3 exports `MMKV` as a class (value + type).

TODO before merge: run the unit-test suite and an iOS/Android smoke
build, plus the in-place upgrade canary scenario from #29195 to confirm
v3 binaries can still read MMKV files that were written by v4 in any
prior dev/internal build (production users are still on v3).

Co-authored-by: Cursor <cursoragent@cursor.com>
@andrepimenta andrepimenta requested a review from a team as a code owner May 19, 2026 15:20
@metamaskbotv2 metamaskbotv2 Bot added the team-mobile-platform Mobile Platform team label May 19, 2026
@github-actions github-actions Bot added pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. size-S labels May 19, 2026
@socket-security

socket-security Bot commented May 19, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​react-native-mmkv@​4.3.1 ⏵ 3.3.310010074 +193 +3100

View full report

@andrepimenta andrepimenta removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 19, 2026
andrepimenta and others added 3 commits May 19, 2026 16:33
The MMKV revert commit picked up incidental SPEC CHECKSUMS drift for four
pods that are unrelated to MMKV (boost, DoubleConversion, fmt, glog).
Their pod versions (boost 1.84.0, DoubleConversion 1.1.6, fmt 11.0.2,
glog 0.3.5) are unchanged on both sides; only the SHA-1 of the podspec
contents shifted. There is no source change that would justify this
drift — the only first-party RN patch
(.yarn/patches/react-native-npm-0.81.5-d8232ef145.patch) touches
ReactAndroid/build.gradle.kts and settings.gradle.kts, neither of which
is an iOS podspec.

The drift almost certainly came from a local CocoaPods/Ruby/Xcode
environment difference when `pod install` was re-run as part of the
MMKV downgrade. The "Check diff" CI job (.github/workflows/ci.yml)
would catch the mismatch by failing on `git diff --exit-code` after a
clean `yarn setup:github-ci`, so revert these four checksums to main's
values to keep the PR diff strictly MMKV-only.

Verified: `git diff main -- ios/Podfile.lock` now shows only the
intended NitroMmkv/MMKVCore removal and react-native-mmkv 3.3.3
addition; no other pod checksums changed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeWalletPlatform, SmokeNetworkAbstractions
  • Selected Performance tags: @PerformanceLaunch, @PerformanceLogin
  • Risk Level: medium
  • AI Confidence: 78%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR downgrades react-native-mmkv from v4 to v3 and migrates all API usages accordingly:

  1. Library downgrade (package.json): react-native-mmkv ^4.1.2^3.2.0
  2. API migration: createMMKV()new MMKV(), remove()delete(), named EventEmitter2 import
  3. Affected files: storage-wrapper.ts (core persistence layer), migrations 049.ts, 106.ts, 136.ts, notification storage, test mocks

Why these tags:

  • StorageWrapper is the core persistence layer used by the entire app for state management. Any regression here would affect all features.
  • The E2E test path uses ReadOnlyNetworkStore (which already has delete() method), so MMKV changes don't directly break E2E storage paths.
  • However, the library downgrade could affect app initialization, state persistence, and migrations on first launch.
  • SmokeAccounts: Account state is persisted via storage; login/unlock flows depend on storage working correctly.
  • SmokeConfirmations: Transaction state persistence depends on storage layer.
  • SmokeWalletPlatform: Core wallet features depend on storage initialization and state persistence.
  • SmokeNetworkAbstractions: Network state is persisted; network selection depends on storage.

Why not all tags: The E2E test path bypasses MMKV entirely (uses ReadOnlyNetworkStore), so the risk is primarily around app startup and state initialization rather than specific feature flows. The changes are API-compatible (same functionality, different method names) and the ReadOnlyNetworkStore already implements the delete() method. A targeted set of smoke tests covering core wallet functionality is sufficient.

Performance Test Selection:
The react-native-mmkv library downgrade (v4→v3) affects the core storage layer used during app startup and login. The StorageWrapper is initialized at app launch and used throughout the login/unlock flow. A library version change could affect storage initialization performance. @PerformanceLaunch covers cold/warm start times which depend on storage initialization, and @PerformanceLogin covers the unlock flow which reads from storage. These are the most directly impacted performance scenarios.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@Cal-L Cal-L left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let’s cp these into 7.78 and 7.79

@tommasini tommasini changed the title chore: revert react-native-mmkv to v3.x chore: revert react-native-mmkv to v3.x cp-7.78.0 May 20, 2026
@andrepimenta andrepimenta added this pull request to the merge queue May 20, 2026
Merged via the queue into main with commit 1d3e8b0 May 20, 2026
279 of 285 checks passed
@andrepimenta andrepimenta deleted the chore/revert-mmkv-v4 branch May 20, 2026 10:13
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-S team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants