'Firebase 9.0.0.8-beta could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds
I've been facing this issue for the past few days. I digged as far as i could on it and couldn't find a solution.
I'm using React Native 0.64.2 and the last Firebase beta release 9.0.0.8 for this project into a react native cli project. Windows and Android emulator are my devices as for today. The error occur once i'm trying to save an user to Firestore. Here is what i get in the console :
ERROR [2021-08-19T15:23:46.836Z] @firebase/firestore: Firestore (9.0.0-beta.8): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds. This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
I'm also getting some warnings, i'm not sure if they are related to this issue tho.
WARN Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground.
WARN Possible Unhandled Promise Rejection (id: 1): FirebaseError: Failed to get document because the client is offline.
WARN [2021-08-19T15:23:46.836Z] @firebase/firestore: Firestore (9.0.0-beta.8): Connection Webchannel transport errored: {"defaultPrevented": false, "g":{"A": true, "J": null, "R": [Circular], "g": {"$": true, "$a": 2, "A": 3, "B": null, "Ba": 12, "C": 0 [and more like that]
At some point, the last warning will keep appearing with few seconds or minutes gap between each. And somehow my user and all his infos got saved in Firestore. It only worked once.
Here are the few things i tried to solve it :
- Checking my code, knowing i just started to usethe new SDK i might have done a mistake
- experimentalForceLongPolling
- Tried with IPv6 and IPv4
- Tried with WIFI and 4G
- Disabled all my firewall and antivirus
- Tried with a new Firebase project
All of that wasn't really successful. Knowing i used the Firebase network tests and everything ran perfecly i'm out of idea.
Here is my code :
const usersRef = collection(db, "users")
const onSignUp = () => {
if(isSelectedSoft === true) {
createUserWithEmailAndPassword(auth, email, password)
.then(res => {
setDoc(doc(usersRef, auth.currentUser.uid), {
email,
pseudo,
mood: "soft",
gender,
age,
country
})
})
.catch(error => {
console.log(error);
});
};
Thanks for your help !
Solution 1:[1]
Are you intending on using the modular Beta? if so, try rolling back a sub version. But ultimately the beta is not recommended for production and these errors should be reported to the beta team.
Additionally, React Native has its own solution for Firebase for React-Native apps called RN-Firebase, I highly suggest using them until they update their API.
Solution 2:[2]
i solved this problem after not using .env variables.
It's not safe, but worked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 |