Skip to content

firebase-js-sdk 10x caused firestore timeout on iOS #8017

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

Closed
gouteru opened this issue Feb 9, 2024 · 9 comments
Closed

firebase-js-sdk 10x caused firestore timeout on iOS #8017

gouteru opened this issue Feb 9, 2024 · 9 comments

Comments

@gouteru
Copy link

gouteru commented Feb 9, 2024

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
@gouteru gouteru added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Feb 9, 2024
@paulinon paulinon removed the new A new issue that hasn't be categoirzed as question, bug or feature request label Feb 9, 2024
@wu-hui
Copy link
Contributor

wu-hui commented Feb 9, 2024

Can you confirm if any of the below version works fine:

10.5.0
10.6.0
10.7.0

@wu-hui wu-hui self-assigned this Feb 9, 2024
@gouteru
Copy link
Author

gouteru commented Feb 10, 2024

Thanks for help, I will check and get back to you after new version of my app release.

@joshhsiao333
Copy link

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

@gouteru
Copy link
Author

gouteru commented Feb 12, 2024

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)

@malnafei
Copy link

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.

@wu-hui
Copy link
Contributor

wu-hui commented Feb 12, 2024

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.

@joshhsiao333
Copy link

const db = initializeFirestore(app, { useFetchStreams: false })
10.8.0 Successed

@gouteru
Copy link
Author

gouteru commented Feb 13, 2024

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.

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 })

@gouteru
Copy link
Author

gouteru commented Sep 29, 2024

The latest version 10.13.2 solved the issue. my app worked with the latest version on iOS.
Thanks

@gouteru gouteru closed this as completed Sep 29, 2024
@firebase firebase locked and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants