Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛] 🔥 Timestamp/FieldValue issues / plus Firestore crashes in iOS Release Mode Only #8401

Open
1 of 9 tasks
cjfritz opened this issue Mar 11, 2025 · 5 comments
Open
1 of 9 tasks
Labels
impact: crash Behaviour causing app to crash. Needs Attention plugin: firestore Firebase Cloud Firestore type: bug New bug report Workflow: Needs Review Pending feedback or review from a maintainer.

Comments

@cjfritz
Copy link

cjfritz commented Mar 11, 2025

Issue

I have recently upgraded my project from v18.9.0 to 21.12.0 (also affects 21.10.0), and it appears that for iOS release variants only, the following crash is occurring when attempting to utilize the Timestamp object from the default export from @react-native-firebase/firestore. Here is the relevant code:

import firestore from '@react-native-firebase/firestore';

export const createFirestoreTimestamp = () => firestore.Timestamp.now();

When the createFirestoreTimestamp function is called, the following crash is reported:

u.default.Timestamp.now is not a function. (In 'u.default.Timestamp.now()', 'u.default.Timestamp.now' is undefined)

I've noticed that when the code is updated to use the named Timestamp class import and make use of its static now method, no crash occurs:

import firestore, { FirebaseFirestoreTypes, Timestamp } from '@react-native-firebase/firestore';

export const createFirestoreTimestamp = () => Timestamp.now(); // this does not crash!

Additionally, I've seen that a usage of FieldArray in my project is also producing a similar crash:

import firestore from '@react-native-firebase/firestore';

dispatch(updateDriverMetadata({ favoriteContacts: firestore.FieldValue.arrayUnion(item.id) }));

Specifically when firestore.FieldValue.arrayUnion is called, the following crash occurs:

n.default.FieldValue.arrayUnion is not a function. (In 'n.default.FieldValue.arrayUnion(l.id)', 'n.default.FieldValue.arrayUnion' is undefined)

I've seen that with v22 coming up, the modular API approach as explained here is favored over default exports, however I did not see any requirements that this needed to occur with v21 or any versions prior in the changelog, even though it appears that the modular functionality is being slowly exposed. Has there possibly been a regression introduced with the modular API compatibility changes? Both Android and iOS debug variants work perfectly fine with the existing code we have implemented, and Android release variants also appear not to be affected.

I saw this current issue open that may be relevant as well: #8369


Project Files

Javascript

Click To Expand

package.json:

  "dependencies": {
    "@react-native-firebase/analytics": "21.12.0",
    "@react-native-firebase/app": "21.12.0",
    "@react-native-firebase/auth": "21.12.0",
    "@react-native-firebase/firestore": "21.12.0",
    "@react-native-firebase/messaging": "21.12.0",
    "@react-native-firebase/remote-config": "21.12.0",
    ...
  }

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# Relevant details of Podfile for react-native-firebase setup:
use_frameworks! :linkage => :static
...
target 'MyApp' do
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseFirestore', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseFirestoreInternal', :modular_headers => true
  pod 'FirebaseRemoteConfig', :modular_headers => true
  pod 'FirebaseABTesting', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true

ios/AppDelegate.mm:

#import <Firebase.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  ...
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
  ...
}


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

System:
  OS: macOS 14.6.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 66.78 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.10.0
    path: ~/.nvm/versions/node/v22.10.0/bin/node
  Yarn: Not Found
  npm:
    version: 10.9.0
    path: ~/.nvm/versions/node/v22.10.0/bin/npm
  Watchman:
    version: 2023.06.12.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/user/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.2 AI-222.4459.24.2221.10121639
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 21.0.3
    path: /Users/user/.sdkman/candidates/java/current/bin/javac
  Ruby:
    version: 3.3.6
    path: /Users/user/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 14.1.0
    wanted: ^14.1.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: ^0.75.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: false
  • Platform that you're experiencing the issue on:
    • [x ] iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • 21.12.0, 21.10.0
  • Firebase module(s) you're using that has the issue:
    • @react-native-firebase/firestore
  • Are you using TypeScript?
    • Y & 5.3.3


@mikehardy
Copy link
Collaborator

Hmm - strange on this one. I did a release build and release test run for iOS in our e2e app and didn't reproduce any problems in the entire firestore e2e suite - but then again it has been transitioned to the named imports you mention don't crash. If the old way of doing things crashes now, then we must be missing something in our test suite

@DevXanderCode
Copy link

i am also facing the same issue

any fix for this ?

@Boldbayar
Copy link

I am facing the same issue with

"@react-native-firebase/app": "^21.12.0",
"@react-native-firebase/auth": "^21.12.0"

@MichaelVerdon MichaelVerdon added platform: ios plugin: firestore Firebase Cloud Firestore blocked: firebase-support Pending feedback or review from google support or response on official sdk repo issue. labels Mar 17, 2025
@mikehardy
Copy link
Collaborator

mikehardy commented Mar 18, 2025

I think there are two things going on - one is that there is a crash in react-native 0.77.1 and 0.78.0 (and still in 0.79.0-rc.2) related to null handling. it only happens in iOS in release mode. See discussion on the upstream PR in this specific comment with a patch I'm testing locally that seems to fix it facebook/react-native#49250 (comment)

The workaround there is to disable new architecture on iOS (unfortunately, I know, not good...) or to apply the patch from that comment (which appears to work for me)

That should resolve this release-mode crash of this issue.

The other part of this issue is related to Timestamp and FieldValue I believe and may be a duplicate of typing issues we are tracking elsewhere. But those should crash in dev as well

Upstream pick requests:

@mikehardy
Copy link
Collaborator

All upstream PRs are picked, and react-native 0.78.1 is released with a fix included - nothing more to do here - upgrading to react-native 0.78.1 is the new recommended solution for the crash

I am leaving this open because it was two issues in fact, and the second issue still needs a look:

  • using Timestamp and FieldValue appears to work using the modular / named exports but fails now in the old namespaced style, something is going on there, as detailed in original post

@mikehardy mikehardy changed the title [🐛] 🔥 Firestore crashes in iOS Release Mode Only [🐛] 🔥 Timestamp/FieldValue issues / plus Firestore crashes in iOS Release Mode Only Mar 20, 2025
@mikehardy mikehardy added Workflow: Needs Review Pending feedback or review from a maintainer. impact: crash Behaviour causing app to crash. and removed platform: ios blocked: firebase-support Pending feedback or review from google support or response on official sdk repo issue. labels Mar 20, 2025
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. Needs Attention plugin: firestore Firebase Cloud Firestore type: bug New bug report Workflow: Needs Review Pending feedback or review from a maintainer.
Projects
None yet
Development

No branches or pull requests

5 participants