Skip to content

Chromium-based browser cannot establish a connection with RealtimeDB #7782

Open
@hadialqattan

Description

Operating System

Windows 11, MacOS 10.14

Browser Version

Google Chrome, Microsoft Edge.. (any chromium-based browser)

Firebase SDK Version

10.6.0

Firebase SDK Product:

Database

Describe your project's tooling

Pure ReactJS app built with Vite.

Describe the problem

Overnight Chromium-based browsers became unable to establish a WebSocket connection with the Firebase RealtimeDB [see logs]
Also, this problem happened to multiple users on multiple networks/OSs.
Additionally, in some devices like mine, it does work perfectly on Chrome.
Moreover, if someone has this problem in his devices and uses Firefox/Safari instead of Chrome, it works fine (this is not a firewall config problem).

Some logs that I've collected from different devices of the error:

photo_2023-11-12_22-56-47
WhatsApp Image 2023-11-10 at 20 04 52_43a159c8
WhatsApp Image 2023-11-13 at 22 51 02_7276118a
hhhh

BTW, I've enforced long-polling and the error persisted!

Steps and code to reproduce issue

This is my config code:

import { FirebaseApp, initializeApp } from 'firebase/app'
import { Auth, getAuth } from 'firebase/auth'
import { Database, getDatabase } from 'firebase/database'

const FIREBASE_API_KEY = import.meta.env.VITE_FIREBASE_API_KEY

// all field are filled in with real data but I replaced them with placeholders here.
const firebaseApp: Readonly<FirebaseApp> = initializeApp({
  apiKey: FIREBASE_API_KEY,
  authDomain: '<auth_domain>',
  projectId: '<project_id>',
  databaseURL: '<my_database_url_id>',
  appId: '<my_app_id>',
  measurementId: '<my_measurementId>'
})

const firebaseAuth: Readonly<Auth> = getAuth(firebaseApp)

const db: Readonly<Database> = getDatabase(firebaseApp)

export { firebaseAuth, db }

And here's the code that causes the problem:

const aFunctionThatGetsCalledOnHomepageMounts = (...): Unsubscribe | null => {
  ...
  return onValue(
    ref(db, path, // db it the same db object mentioned in the code snippet above (imported).
    (snapshot) => {
     ...
    }
  )
}

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions