React Native Firebase Firestore - [firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition

Viewed 93

My firestore connection was working fine for the past few months until today when I received this error after a user authenticates via firebase authentication (email/password) and I try to query a firestore document.

I've gone through all the posts about this error and nothing has worked for me.

Error: [firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.

My package.json looks like this for the react-native-firebase dependency (I updated to the latest):

    "@react-native-firebase/analytics": "^15.3.0",
    "@react-native-firebase/app": "^15.3.0",
    "@react-native-firebase/auth": "^15.3.0",
    "@react-native-firebase/database": "^15.3.0",
    "@react-native-firebase/firestore": "^15.3.0",
    "@react-native-firebase/storage": "^15.3.0",
    "react-native": "0.64.0",

This is how I'm calling the firestore function after a user authenticates:

auth().onAuthStateChanged(async (authUser) => {
  console.log(authUser);
  if (authUser) {

    // console.log(firestore);


    const banner = await firestore()
      .collection('banner')
      .doc(authUser.uid)
      .get();

I console log the authuser and firestore, and both are logged right away after the user authenticates so I know that authentication is working and the correct instance of firestore is present. But I keep running into this error of firestore being unavailable.

This is only occurring on my iOS simulator, not my Android emulator. I've erased all content on the iOS simulator and reinstalled the developer app, but that didn't work.

I also followed this blog post and disabled/enabled the token service api, but that didn't work either: https://medium.com/@chonnaronghanyawongse/coding-diary-why-my-firestore-doesnt-work-2db41fb82121

I'm not using VPN and my internet is stable. I've also changed the firestore rules to be true for both read and write to make sure it's not a permissions issue.

What's odd is that if I refresh the app after the error occurs, there's no issues with retrieving documents from firestore. It's when I open the app for the first time and authenticate, that's when I see this error.

I've even checked out previous versions of my app when firestore was working fine and I see the error now on the first time I authenticate. So I'm assuming this is an issue with the iOS simulator perhaps?

Would really appreciate anyone's help on this or if anyone has been in a similar situation and found a solution that worked for them! Thank you so much!

0 Answers
Related