firebase-js-sdk
firebase-js-sdk copied to clipboard
firebase-js-sdk 10x caused firestore timeout on iOS
Operating System
MacOS 14.3
Browser Version
cordova-ios 6.3.0
Firebase SDK Version
10.7.2 and 10.8.0
Firebase SDK Product:
Firestore
Describe your project's tooling
cordova 12.0.0 cordova ios 6.3.0 cordova-plugin-firebase-messaging 8.0.1 (FirebaseCore, FirebaseMessaging 10.10) Vue 2.6.4
Xcode15.2 iOS 17.2
Describe the problem
When I updated firebase-js-sdk from 9.23.0 to 10.7.2, and running my app on iPhone device with Xcode, then timeout error below displayed in Xcode debug console. I swiched firebase-js-sdk to 10.8.0, same output displayed. 100% everytime reproduced. Then I reverted version 9.23.0 of firebase-js-sdk, the error was solved. (I have not tried between versions 9.23.0 to 10.7.2.)
ERROR: [2024-02-06T11:55:35.017Z]
@firebase/firestore: Firestore (10.8.0):
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.
ERROR: Error getDoc:
FirebaseError: [code=unavailable]:
Failed to get document because the client is offline.
Running on other platforms such as Mac Chrome, Android device with Android Studio are okay with firebase-js-sdk 10.7.2 and 10.8.0.
Please help so that I can update firebase-js-sdk to the latest.
Steps and code to reproduce issue
Here's the code, experimentalForceLongPolling has been set true.
import firebaseApp from '../initializeApp'
import { getAuth, onAuthStateChanged } from 'firebase/auth'
import { initializeFirestore, doc, getDoc, setDoc, updateDoc, writeBatch, collection, getDocs, query, where } from 'firebase/firestore'
import common from '../util/common'
import comLs from '../util/com_localstorage'
const db = initializeFirestore(firebaseApp, { experimentalForceLongPolling: true })
const auth = getAuth(firebaseApp)
const docRef = doc(db, 'operations', 'services')
const docSnap = await getDoc(docRef) <<<----- caused error
Can you confirm if any of the below version works fine:
10.5.0 10.6.0 10.7.0
Thanks for help, I will check and get back to you after new version of my app release.
I have the same "Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds." problem. solved by downgrade to firebase-js-sdk to 10.6.0
Can you confirm if any of the below version works fine:
10.5.0 10.6.0 10.7.0
Here's the results of versions.
10.8.0 timeout error 10.7.2 timeout error 10.7.0 timeout error 10.6.0 Succeeded (*1) 10.5.0 timeout error (*1) 9.23.0 Succeeded
(*1) WebContent process (0x1100180c0) took 1.082477 seconds to launch Xcode log was output at the first boot of app. second time and after the error never showed up.
Also, this might be another issue but I have a concern. with version 9.23.0, If I stated import firebase/messaging in my Vue js code, my app not launched with Xcode with no log output. my app uses cordova-plugin-firebase-messaging for push notification, so js messaging is not needed to import and no problem but I am not sure why?
In my Vue.js code
import firebaseApp from '../initializeApp'
import { getAuth, onAuthStateChanged } from 'firebase/auth'
// import { getMessaging, getToken, onMessage } from 'firebase/messaging' <<<< ----- this line needs tobe commentout for iOS, why?
import { initializeFirestore, doc, getDoc, setDoc, updateDoc, writeBatch, collection, getDocs, query, where } from 'firebase/firestore'
const db = initializeFirestore(firebaseApp, { experimentalForceLongPolling: true })
const auth = getAuth(firebaseApp)
// const messaging = getMessaging(firebaseApp)
Hey everyone,
As a Firebase GDE, I wanted to share my experience regarding this issue. I can confirm that version 10.6.0 does not exhibit the problem, but any version released after 10.6.0 fails to work as expected. I have already reported this issue to Firebase support for further investigation.
In the meantime, I recommend sticking with version 10.6.0 until the Firebase team identifies and resolves the underlying cause. There's a possibility that an upcoming version will include the necessary fix. Thank you for your patience and understanding.
Hi @gouteru
Thank you for trying out different versions!
Do you mind experiment with one more thing:
Set useFetchStreams = false in Firestore settings at the initialization of the SDK(https://firebase.google.com/docs/reference/js/firestore_.md#initializefirestore_fc7d200). useFetchStreams does not seems to exist in the ref docs, but it does exist (might be another issue we need to fix).
You only need to experiment in any version newer than 10.6.0 that does have the problem.
const db = initializeFirestore(app, { useFetchStreams: false })
10.8.0 Successed
Hi @gouteru
Thank you for trying out different versions!
Do you mind experiment with one more thing:
Set
useFetchStreams = falsein Firestore settings at the initialization of the SDK(https://firebase.google.com/docs/reference/js/firestore_.md#initializefirestore_fc7d200).useFetchStreamsdoes not seems to exist in the ref docs, but it does exist (might be another issue we need to fix).You only need to experiment in any version newer than 10.6.0 that does have the problem.
I have installed firebase-js-sdk 10.8.0 and set useFetchStreams: fale with 2 patterns below.
Unfortunatelly, it's not work for my case.
const db = initializeFirestore(firebaseApp, { experimentalForceLongPolling: true, useFetchStreams: false })
const db = initializeFirestore(firebaseApp, { useFetchStreams: false })
These 2 patterns resulted freeze at splash screen of my app and stopped console log output on Xcode after cordova plugins loaded.
And I reverted the line as before. This caused the timeout error.
const db = initializeFirestore(firebaseApp, { experimentalForceLongPolling: true })