-
Notifications
You must be signed in to change notification settings - Fork 927
"Could not reach Cloud Firestore backend" after upgrading to v9 #5667
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
Comments
The issue is caused by Therefore, please change your code accordingly: import {initializeFirestore} from 'firebase/firestore'
const db = initializeFirestore(firebaseApp, {useFetchStreams: false}) There is a new PR #5643 by @schmidt-sebastian which is already merged which will automatically set it to EDIT: |
@edi Thanks for the comment! The fetch fix for RN should be released this week. For |
@Feiyang1 Oh, so you’re implying PhoneAuth will not be available as of v9 anymore? If so, that’s gonna be a big bummer. Is there any reasoning behind making it unavailable for RN? We use PhoneAuth in multiple apps, and it works just fine so far. |
Thanks @edi, does that mean I should replace the getFirestore with initializeFirestore? I want to read more on initializeFirestore but I can't seem to find the docs on it, could you help point me in the right direction? |
Correct, change your import and your firestore (const db) line as per my example, then you’re good to go. |
@edi IIUC, PhoneAuth relies on recaptcha to work, which wouldn't work in RN. The auth lib in v8 is monolithic, and provide a single bundle for all environments, while v9 provide different bundles for different environments, so we can define the API differently depending on what is supported in a specific environment. I don't think PhoneAuth works in RN even with v8. Is it not the case? |
Brilliant, thank you. I'm using typescript. Is there an appropriate settings type to use for this config object? I see the |
@Feiyang1 You're both right, and wrong. No (pure) RN user is probably going to post about this issue, but I understand where the confusion is coming from. I alongside probably all users who noticed about this being an issue, are coming from Expo, which has it's own recaptcha module, which gives us the option to use So, to answer your question, yes, that is the case, we have been using We're currently standing by, waiting on @sam-gc to properly expose those within RN, so that we can properly publicly deploy our newly ported apps to v9. |
@angusryer You're right. As per the API Reference it seems that TS definitions do not include On another hand, you may work around this, until #5643 makes it to the live build, by using the same That should get you going for the time being, even though it's a little bit more intrusive. |
That's so strange, I tried that and it didn't work await console.log('Initializing Firebase App...')
const firebaseApp = await initializeApp({
apiKey: "xxxxxxxxxxx",
authDomain: "xxxxxx",
projectId: "xxxxxx",
})
console.log('App Initialized, Initializing Firestore...')
db = await initializeFirestore(firebaseApp, {useFetchStreams: false, experimentalForceLongPolling:true}) this still throws the error. Why? |
@Shashank-Prasanna & @edi I hadn't replied back, but For anyone using Typescript, you can extend the // `FirestoreSettings` interface extends `PrivateSettings` which contains `useFetchStreams`.
const firestoreSettings: FirestoreSettings & { useFetchStreams: boolean } = {
useFetchStreams: false
};
export const fsdb = initializeFirestore(app, firestoreSettings); And with that I'm no longer getting the original error. |
I tried this but the original error comes up and I also get another error: Here's my full code: import { initializeApp } from 'firebase/app'
import { initializeFirestore } from 'firebase/firestore'
console.log('config.js')
const firebaseApp = initializeApp({
apiKey: "xxxxxxxx",
authDomain: "xxxxxxxx",
projectId: "xxxxxxxx",
})
console.log('DB initialized')
const firestoreSettings: FirestoreSettings & { useFetchStreams: boolean} ={
useFetchStreams: false,
}
const db = initializeFirestore(firebaseApp, firestoreSettings)
export default db for context, I am using expo-cli with an iOS device on react native The really odd thing is that when I try it out on my PC in chrome, it works! But when I try it out on iOS in the expo go app, it throws the error |
Right @Shashank-Prasanna you'll have to remove the type defs if you're not using Typescript: const firestoreSettings = {
useFetchStreams: false
} When testing this using the web, I also do not get the error. I haven't tested on an Android device. |
@angusryer The odd thing is that this works only in a web browser... when I use the React Native web app on my iOS phone (with expo and expo go), the error still arises. Perhaps it is related to this warning I always receive?
I never receive this error in a web browser, yet I do on iOS (haven't tested on Android). I can't understand for the life of me why this happens! |
|
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
I just started updating my code from Firebase v8 to v9 and then started running into this issue (which is weird because it was just working before I upgraded to v9 so I'm pretty sure it's not a network issue)
It seems like some firebase features do work, for eg the onAuthStateChange from firebase.auth, but whenever I try and run a Firestore command it seems to get stuck.
Relevant Code:
The text was updated successfully, but these errors were encountered: