Skip to content
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

@firebase/firestore: Firestore (9.23.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unavailable]: The operation could not be completed 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. #8576

Open
juan-carvajal opened this issue Oct 16, 2024 · 3 comments

Comments

@juan-carvajal
Copy link

Operating System

Multiple operating systems, mostly iOS and Android

Environment (if applicable)

Multiple browsers, mostly mobile versions of Safari and Chrome

Firebase SDK Version

9.23.0

Firebase SDK Product(s)

Firestore

Project Tooling

Vue 3 SPA app, created with Quasar framework V2. Package using Vite.

Detailed Problem Description

Some of our users have encountered an issue where our application does not start from the corporate network. We found that the listener has a slow response time that is not within the timeout of 10 seconds, i.e. the request does not go through and the application does not receive data from firebase.

This is what my setup looks now:

import { initializeApp } from 'firebase/app';
import {
  connectFirestoreEmulator,
  initializeFirestore,
  setLogLevel,
  onSnapshotsInSync,
} from 'firebase/firestore';
import { getAuth, connectAuthEmulator } from 'firebase/auth';
import { getPerformance } from 'firebase/performance';
import { getAnalytics } from 'firebase/analytics';
import { getStorage, connectStorageEmulator } from 'firebase/storage';
import { getFunctions, connectFunctionsEmulator } from 'firebase/functions';
import { boot } from 'quasar/wrappers';
import { useAuthStore } from 'src/stores/auth-store';

const firebaseConfig = {
 ...
};

const firebaseApp = initializeApp(firebaseConfig);

setLogLevel('debug');
const db = initializeFirestore(firebaseApp, {
  experimentalForceLongPolling: true,
  experimentalLongPollingOptions: {
    timeoutSeconds: 30,
  },
});
const performance = getPerformance(firebaseApp);
const auth = getAuth(firebaseApp);
const analytics = getAnalytics(firebaseApp);
const storage = getStorage(firebaseApp);
const functions = getFunctions(firebaseApp);

// Algunas veces falla el emulator de autenticación
// Cuando se encuentra dentro de la función boot

if (process.env.DEV && process.env.USE_AUTH_EMULATOR == 'true') {
  connectAuthEmulator(auth, 'http://127.0.0.1:9099', { disableWarnings: true });
}

export default boot(() => {
  const { handleUserChange } = useAuthStore();
  if (process.env.DEV) {
    connectFirestoreEmulator(db, 'localhost', 8081);
    connectStorageEmulator(storage, 'localhost', 9199);
    connectFunctionsEmulator(functions, 'localhost', 5001);
  }
  auth.onAuthStateChanged(handleUserChange);

  onSnapshotsInSync(db, {
    next: (metadata) => {
      console.log('Snapshots in sync', metadata);
    },
    error: (error) => {
      console.error('Error in snapshots in sync', error);
    },
    complete: () => {
      console.log('Snapshots in sync complete');
    },
  });
});

export { auth, db, performance, analytics, storage, functions };

Setting experimentalAutoDetectLongPolling or experimentalForceLongPolling does not help.

Results from https://debug-my.firebaseapp.com/ found in test.txt
Browser trace after setLogLevel('debug') found in log.txt

Steps and code to reproduce issue

No idea, this appears to happen intermittently and is more prevalent with certain ISP/mobile internet providers (TIGO). This is not an isolated case; most errors come from mobile devices. There should be sufficient internet speed in most cases, but the error still shows up. 99% of our users are from Colombia.

@juan-carvajal juan-carvajal added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Oct 16, 2024
@juan-carvajal juan-carvajal changed the title Title for @firebase/firestore: Firestore (9.23.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unavailable]: The operation could not be completed 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.the bug @firebase/firestore: Firestore (9.23.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unavailable]: The operation could not be completed 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.the bug Oct 16, 2024
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@juan-carvajal juan-carvajal changed the title @firebase/firestore: Firestore (9.23.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unavailable]: The operation could not be completed 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.the bug @firebase/firestore: Firestore (9.23.0): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=unavailable]: The operation could not be completed 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. Oct 16, 2024
@jbalidiong jbalidiong added api: firestore needs-attention and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request labels Oct 16, 2024
@wu-hui wu-hui self-assigned this Oct 21, 2024
@wu-hui
Copy link
Contributor

wu-hui commented Oct 21, 2024

From you logs, it seems like the connection was recovered later? Is this what you observed as well?

You can also try to upgrade to the latest, we have done some changes to our network transportation layer recently that might be helpful.

@google-oss-bot
Copy link
Contributor

Hey @juan-carvajal. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants