0

I have made my React Native App with Expo and firebase and used realtime database in that.

Suddenly I started getting app crashes from the users and got to know that randomly users are getting error "Cannot read property 'sendRequest' of null" and app crashes and source is firebase.

I was using Firebase Realtime Database for a long time and this problem was occuring in the last 3 months. I have tried solving everything Google Searched, Gemini, ChatGPT, Claude, reading documentations beleive me everything and my startup is dependent on this.

Error occur when I export updateOnFirebase, createOnFirebase etc and use it in another files.

This error dont occur while I am in development mode, just occurs when I am in production mode after publishing app to Google Play Store ( presumably when internet is slightly weak )

I have made these kind of functions and exported them and used them in my entire app

Firebase version "firebase": "^9.23.0"

import { initializeApp } from "firebase/app";
import { getStorage } from "firebase/storage";
import { getDatabase } from "firebase/database";
import { ref, push, onValue, set, update, get, remove } from "firebase/database";

// Initialize Firebase, Done this way to not initialzie multiple times
const firebaseApp = initializeApp(firebaseConfig);

// Initializing Firebase services
export const db = getDatabase(firebaseApp);


// export const updateOnFirebase = async ({ updates }) => {
//   try {
//     await update(ref(db), updates);
//   } catch (error) {
//     handleError(error, "Error in updateOnFirebase", updates);
//   }
// };

Updates I have found similar random bugs here which are very very related in Randomness

  1. Randomness Very related to this bug -> https://github.com/software-mansion/react-native-screens/issues/1661
  2. https://github.com/Kureev/react-native-blur/issues/595
  3. https://github.com/software-mansion/react-native-screens/issues/1685

All of these are Random and many predictions are there but no exact reproducible way unfortunately

6
  • 1
    Please edit the question to show the line of code that causes the problem. None of what you're showing here so far is likely to cause that error, and we can't help you debug this without a complete minimal reproducible example of the code that doesn't work the way you expect. Commented Feb 27 at 15:18
  • Thanks @DougStevenson for taking the time to read the question, Unfortunately this error is only occuring in production, not while I am developing builds. In my last 5 years of development, I am very amazed, I have never encountered any such thing. Even in production build this error occurs randomly meaning 90% times it works great on the same screen and 10% time it fails randomly. Commented Feb 27 at 19:27
  • @Harshitsharma Can you please provide the complete code snippet. The error mentioned is not related to the code which you have shown. As you mentioned that error occurs only when using "updateOnFirebase" this from another file then may be the instances are not been correctly initialized. In debug mode generally app runs bit slow as compared to in production. So may be somewhere the order of calling methods and their references initialization is causing issue. So please provide complete code snippet in github if possible. Commented Mar 5 at 18:43
  • Since your app works in development but fails in production with weak internet, Firebase may be struggling to maintain a connection. You can enable offline persistence to allow updates to be queued and retried when the connection is restored. Commented Mar 7 at 7:19
  • When in development mode, did you make tests with network throttling to simulate the conditions where the issue arises? If not, then I'd start there and you may be able to reproduce it Commented Mar 7 at 21:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.