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

"the client is offline." but it's not the case #6036

Closed
wneel opened this issue Feb 27, 2022 · 36 comments · Fixed by #6340
Closed

"the client is offline." but it's not the case #6036

wneel opened this issue Feb 27, 2022 · 36 comments · Fixed by #6340

Comments

@wneel
Copy link

wneel commented Feb 27, 2022

[REQUIRED] Describe your environment

  • Operating System version: windows 10 (v21H2)
  • Browser version: react-native 0.67.3
  • Firebase SDK version: 9.6.7
  • Firebase Product: database , firestore , auth

[REQUIRED] Describe the problem

I saw the #5836 and many others on Stack Overflow, i'm facing the same issue i recreated a few time test projects to try connect to Firestore but since i am using firebase v9 modular i can't access the database, same problem on my physical device (SM-A520F - 8.0.0) android 8 and on many emulators using android studio (Pixel, Pixel 2, Pixel 3, Pixel 4) different android version from 8 to 10.

the error is always the same :
ERROR [2022-02-27T23:03:53.595Z] @firebase/firestore: Firestore (9.6.7): 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.

LOG [FirebaseError: Failed to get document because the client is offline.]

Steps to reproduce:

  1. Create react app using npx react-native init AppName

  2. Install firebase : npm i firebase

  3. Go in App.js and try this :

Relevant Code:

//App.js
import React from 'react';
import {
  Text,
  View,
  TouchableOpacity
} from 'react-native';

import { initializeApp } from 'firebase/app';
import { getFirestore, doc, getDoc } from "firebase/firestore";


const firebaseConfig = {

  apiKey: "AIzaSyB-57*****************************",

  authDomain: "***********.firebaseapp.com",

  projectId: "***********",

  storageBucket: "***********.appspot.com",

  messagingSenderId: "28**********",

  appId: "1:28*************************************",

  measurementId: "G-5*********"

};

const app = initializeApp(firebaseConfig);

const Firestore = getFirestore(app)

const App = () => {

  async function onPress() {

    const my_doc = await getDoc(doc(Firestore, '/CollectionName/DocumentID'))

    console.log(my_doc.data())

  }

  return (
    <View>
      <TouchableOpacity
        onPress={onPress}
      >
        <Text>Press Here</Text>
      </TouchableOpacity>
    </View>
  );
};

export default App;

when i press the Text i wait 10-12s and the console return me the error above, the exact same error on all my support, i have did all my test with the same PC, i will try on another asap.

I am stuck with this from a long time now and i don't understand the problem, i have a excellent connection (more than 100mb/s) when i do speedtest on my device or my emulators.

@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.

@wu-hui
Copy link
Contributor

wu-hui commented Mar 1, 2022

Although I am not sure what exactly it is, using Firestore JS SDK in React Native has always met with connection issues like this. While I will try to troubleshoot this, I think you might be better off to try https://github.com/invertase/react-native-firebase instead.

@wneel
Copy link
Author

wneel commented Mar 2, 2022

I think you might be better off to try https://github.com/invertase/react-native-firebase instead.

The advantage of v9 modular is the final size of the project is majorly reduced, if i use rn-firebase would i take advantage of the v9 like with the real firebase or not ?

@schmidt-sebastian
Copy link
Contributor

https://github.com/invertase/react-native-firebase uses the Android or iOS SDK under the hood and not the Web SDK. There is currently no tree-shaking.

@schmidt-sebastian
Copy link
Contributor

Can you invoke setLogLevel('debug') and share the logs?

This is what I am seeing:

 LOG  [2022-03-02T20:05:00.812Z]  @firebase/firestore: Firestore (9.6.7): FirebaseAuthCredentialsProvider Auth not yet detected
 LOG  [2022-03-02T20:05:00.813Z]  @firebase/firestore: Firestore (9.6.7): FirestoreClient Using default OnlineComponentProvider
 LOG  [2022-03-02T20:05:00.813Z]  @firebase/firestore: Firestore (9.6.7): FirestoreClient Using default OfflineComponentProvider
 LOG  [2022-03-02T20:05:00.814Z]  @firebase/firestore: Firestore (9.6.7): FirestoreClient Initializing OfflineComponentProvider
 LOG  [2022-03-02T20:05:00.816Z]  @firebase/firestore: Firestore (9.6.7): FirestoreClient Initializing OnlineComponentProvider
 LOG  [2022-03-02T20:05:00.819Z]  @firebase/firestore: Firestore (9.6.7): MemoryPersistence Starting transaction: Allocate target
 LOG  [2022-03-02T20:05:00.822Z]  @firebase/firestore: Firestore (9.6.7): MemoryPersistence Starting transaction: Execute query
 LOG  [2022-03-02T20:05:00.823Z]  @firebase/firestore: Firestore (9.6.7): QueryEngine Using full collection scan to execute query: Query(target=Target(CollectionName/DocumentID, orderBy: [__name__ (asc)]); limitType=F)
 LOG  [2022-03-02T20:05:00.827Z]  @firebase/firestore: Firestore (9.6.7): Connection Creating WebChannel: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel {"httpSessionIdParam":"gsessionid","initMessageHeaders":{"X-Goog-Api-Client":"gl-js/ fire/9.6.7","Content-Type":"text/plain","X-Firebase-GMPID":"***"},"messageUrlParams":{"database":"projects/***/databases/(default)"},"sendRawJson":true,"supportsCrossDomainXhr":true,"internalChannelParams":{"forwardChannelRequestTimeoutMs":600000},"forceLongPolling":false,"detectBufferingProxy":false}
 LOG  [2022-03-02T20:05:00.829Z]  @firebase/firestore: Firestore (9.6.7): FirebaseAppCheckTokenProvider AppCheck not yet detected
 LOG  [2022-03-02T20:05:00.830Z]  @firebase/firestore: Firestore (9.6.7): Connection Opening WebChannel transport.
 LOG  [2022-03-02T20:05:00.832Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel sending: {"database":"projects/***/databases/(default)","addTarget":{"documents":{"documents":["projects/***/databases/(default)/documents/CollectionName/DocumentID"]},"targetId":2}}
 LOG  [2022-03-02T20:05:01.404Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel transport opened.
 LOG  [2022-03-02T20:05:01.500Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel received: {"targetChange":{"targetChangeType":"ADD","targetIds":[2]}}
 LOG  [2022-03-02T20:05:01.500Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel received: {"documentDelete":{"document":"projects/***/databases/(default)/documents/CollectionName/DocumentID","readTime":"2022-03-02T20:05:01.382876Z","removedTargetIds":[2]}}
 LOG  [2022-03-02T20:05:01.500Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel received: {"targetChange":{"targetChangeType":"CURRENT","targetIds":[2],"resumeToken":"CgkI3NnN35yo9gI=","readTime":"2022-03-02T20:05:01.382876Z"}}
 LOG  [2022-03-02T20:05:01.500Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel received: {"targetChange":{"resumeToken":"CgkI3NnN35yo9gI=","readTime":"2022-03-02T20:05:01.382876Z"}}
 LOG  [2022-03-02T20:05:01.504Z]  @firebase/firestore: Firestore (9.6.7): MemoryPersistence Starting transaction: Get last remote snapshot version
 LOG  [2022-03-02T20:05:01.506Z]  @firebase/firestore: Firestore (9.6.7): MemoryPersistence Starting transaction: Apply remote event
 LOG  [2022-03-02T20:05:01.510Z]  @firebase/firestore: Firestore (9.6.7): MemoryPersistence Starting transaction: notifyLocalViewChanges
 LOG  [2022-03-02T20:05:01.511Z]  @firebase/firestore: Firestore (9.6.7): MemoryPersistence Starting transaction: Release target
 LOG  undefined
 LOG  [2022-03-02T20:05:01.515Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel sending: {"database":"projects/***/databases/(default)","removeTarget":2}
 LOG  [2022-03-02T20:05:01.564Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel received: {"targetChange":{"targetChangeType":"REMOVE","targetIds":[2]}}

@schmidt-sebastian schmidt-sebastian self-assigned this Mar 2, 2022
@fac-torize
Copy link

I got the same issue but only on android. iOS is working just fine.

@wneel
Copy link
Author

wneel commented Mar 4, 2022

this is the log i got by Importing SetLogLevel from 'firebase/firestore' when i imported it from 'firebase/app' i didn't get anything :

 LOG  Running "testXconnection" with {"rootTag":11}
 LOG  [2022-03-04T16:43:17.505Z]  @firebase/firestore: Firestore (9.6.7): FirebaseAuthCredentialsProvider Auth not yet detected
 LOG  [2022-03-04T16:43:17.516Z]  @firebase/firestore: Firestore (9.6.7): FirestoreClient Using default OnlineComponentProvider
 LOG  [2022-03-04T16:43:17.519Z]  @firebase/firestore: Firestore (9.6.7): FirestoreClient Using default OfflineComponentProvider
 LOG  [2022-03-04T16:43:17.519Z]  @firebase/firestore: Firestore (9.6.7): FirestoreClient Initializing OfflineComponentProvider
 LOG  [2022-03-04T16:43:17.522Z]  @firebase/firestore: Firestore (9.6.7): FirestoreClient Initializing OnlineComponentProvider
 LOG  [2022-03-04T16:43:17.527Z]  @firebase/firestore: Firestore (9.6.7): MemoryPersistence Starting transaction: Allocate target
 LOG  [2022-03-04T16:43:17.532Z]  @firebase/firestore: Firestore (9.6.7): MemoryPersistence Starting transaction: Execute query
 LOG  [2022-03-04T16:43:17.534Z]  @firebase/firestore: Firestore (9.6.7): QueryEngine Using full collection scan to execute query: Query(target=Target(CollectionName/DocumentID, orderBy: [__name__ (asc)]); limitType=F)
 LOG  [2022-03-04T16:43:17.540Z]  @firebase/firestore: Firestore (9.6.7): Connection Creating WebChannel: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel {"httpSessionIdParam":"gsessionid","initMessageHeaders":{"X-Goog-Api-Client":"gl-js/ fire/9.6.7","Content-Type":"text/plain","X-Firebase-GMPID":"1:1055076983185:web:2338e7c6417ea4c5d77a30"},"messageUrlParams":{"database":"projects/textxconnection/databases/(default)"},"sendRawJson":true,"supportsCrossDomainXhr":true,"internalChannelParams":{"forwardChannelRequestTimeoutMs":600000},"forceLongPolling":false,"detectBufferingProxy":false}
 LOG  [2022-03-04T16:43:17.544Z]  @firebase/firestore: Firestore (9.6.7): FirebaseAppCheckTokenProvider AppCheck not yet detected
 LOG  [2022-03-04T16:43:17.547Z]  @firebase/firestore: Firestore (9.6.7): Connection Opening WebChannel transport.
 LOG  [2022-03-04T16:43:17.549Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel sending: {"database":"projects/textxconnection/databases/(default)","addTarget":{"documents":{"documents":["projects/textxconnection/databases/(default)/documents/CollectionName/DocumentID"]},"targetId":2}}
 LOG  [2022-03-04T16:43:17.837Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel transport opened.
 ERROR  [2022-03-04T16:43:27.547Z]  @firebase/firestore: Firestore (9.6.7): 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.
 LOG  [2022-03-04T16:43:27.588Z]  @firebase/firestore: Firestore (9.6.7): MemoryPersistence Starting transaction: Release target
 LOG  [2022-03-04T16:43:27.598Z]  @firebase/firestore: Firestore (9.6.7): Connection WebChannel sending: {"database":"projects/textxconnection/databases/(default)","removeTarget":2}
 WARN  Possible Unhandled Promise Rejection (id: 0):
FirebaseError: Failed to get document because the client is offline.
construct@[native code]
Wrapper@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:22813:64
construct@[native code]
_createSuperInternal@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:110646:322
FirebaseError@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:111260:27
construct@[native code]
_createSuperInternal@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:113611:322
Q@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:113850:26
next@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:131303:55
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:130246:30
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:29541:26
_callTimer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:29461:17
callTimers@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:29662:19
__callFunction@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:3056:36
http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:2780:31
__guard@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:3007:15
callFunctionReturnFlushedQueue@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false&app=com.testxconnection&modulesOnly=false&runModule=true:2779:21
callFunctionReturnFlushedQueue@[native code]

i didn't hide anything because this is a test project just for this issue so here is the logs

@wneel
Copy link
Author

wneel commented Mar 4, 2022

And i would like to test on IOS, i have an Iphone but not a macbook so i can't currently test running on IOS

@schmidt-sebastian
Copy link
Contributor

The log looks (I am a bit surprised there is no initiating of a backoff attempt though). I am unfortunately not able to reproduce this on iOS at the moment, but should be in a couple of days. In the meantime, if you have some spare cycles it would be interesting to see if you can use "firebase/firestore/lite" which uses plain HTTP for its networking. It does not support offline usage and onSnapshot listeners though.

@dbanisimov
Copy link

I've started seeing this error on an app deployed in production that hasn't seen any changes in a while. Firebase SDK version: 9.6.5 and 9.6.8 as well. Multiple browsers.

Could it be something with AppCheck? The only change I see in the console is that starting today AppCheck is reporting client requests for Firestore in our project. Enforcing is not enabled though.

@patrickk
Copy link

patrickk commented Mar 4, 2022

Also have seen this since this morning ~11AM ET. We are on 9.6.1 + React for web.

It also intermittently happens, some devs are able to reproduce while others aren't.

@dbanisimov
Copy link

I've started seeing this error on an app deployed in production that hasn't seen any changes in a while. Firebase SDK version: 9.6.5 and 9.6.8 as well. Multiple browsers.

Could it be something with AppCheck? The only change I see in the console is that starting today AppCheck is reporting client requests for Firestore in our project. Enforcing is not enabled though.

In our case a third-party script (FullStory session recording) was interfering with Firestore requests. I don't know how it is intercepting XHR requests and what changed today in their script, but once we disabled it the Firestore issue went away. Sorry folks for polluting this issue, but maybe this will offer some clues on what might be the cause here.

@wneel
Copy link
Author

wneel commented Mar 5, 2022

it would be interesting to see if you can use "firebase/firestore/lite"

 LOG  Running "testXconnection" with {"rootTag":1}
 LOG  [2022-03-05T16:32:08.141Z]  @firebase/firestore: Firestore (9.6.7_lite): ComponentProvider Initializing Datastore
 LOG  [2022-03-05T16:32:08.198Z]  @firebase/firestore: Firestore (9.6.7_lite): RestConnection Sending:  https://firestore.googleapis.com/v1/projects/textxconnection/databases/(default)/documents:batchGet {"documents":["projects/textxconnection/databases/(default)/documents/CollectionName/DocumentID"]}
 LOG  [2022-03-05T16:32:08.443Z]  @firebase/firestore: Firestore (9.6.7_lite): RestConnection Received:  [{"found":{"name":"projects/textxconnection/databases/(default)/documents/CollectionName/DocumentID","fields":{"test":{"stringValue":"test String value"}},"createTime":"2022-03-04T16:40:40.128561Z","updateTime":"2022-03-04T16:40:40.128561Z"},"readTime":"2022-03-05T16:32:07.583541Z"}]
 LOG  {"test": "test String value"} 

Last line is the value stored in Firestore so it's worked maybe the issue come from a Firewall or i don't know i have no antivirus and disabled windows Defender so it's maybe coming from Android studio / Metro ? i try to see because I'll need to use onSnapshot listeners

Edit : Or maybe i can force request of the 'firebase/firestore" to be HTTP i currently don't find a way, every google searches redirect me to Firebase functions i continue searching.

@Nantris
Copy link

Nantris commented Mar 6, 2022

Also seeing this with React Native on Android 12.

@schmidt-sebastian
Copy link
Contributor

@sampajano

@Nantris
Copy link

Nantris commented Mar 16, 2022

Seeing this intermittently on Linux too, in Electron.


Edit: @schmidt-sebastian did you mean to assign this to @sampajano or yourself?

@sampajano
Copy link
Contributor

Hi :) Could you try to enable the experimentalAutoDetectLongPolling flag and see if it solves the issue for you? Thanks! 😃

Code:

firebase.firestore().settings({ experimentalAutoDetectLongPolling: true });

@wneel
Copy link
Author

wneel commented Mar 18, 2022

Hi, it worked perfectly,
for maybe future readers i imported like this :
import { initializeFirestore } from 'firebase/firestore'

and used it like this :

const db = initializeFirestore(app, {
  experimentalAutoDetectLongPolling: true
})

because i'm in v9

Thank you so much it is even faster than before ! :)

@wneel wneel closed this as completed Mar 18, 2022
@sampajano
Copy link
Contributor

Fantastic! Glad it worked and thanks for sharing the results! 😃

@Nantris
Copy link

Nantris commented Mar 31, 2022

What about Realtime Database?

and @sampajano what about cases where this error is caused by pausing the code for a few seconds in the debugger? (Edit: Actually it occurs in the debugger almost 100% of the time, even if there's no pausing, but only if a user is signed in, but probably because that's the only time we register listeners.)

It says it's offline even milliseconds before our listeners fire off actions in response to, apparently, being online. Maybe I'm just being fooled by offline persistence though?

@x-Wawa would you please re-open this issue?

@wneel wneel reopened this Apr 11, 2022
@schmidt-sebastian schmidt-sebastian removed their assignment Apr 14, 2022
@codescooper
Copy link

hello, i'm facing the same problem
and the solution of @x-Wawa not orke for me :'(
anyone have some explanation about it ?

@LanderBeeuwsaert
Copy link

LanderBeeuwsaert commented May 4, 2022

Hi all, fyi, since moving a big part of our existing codebase to modular firebase we've also started to experience this issue frequently.
Both in our CI testing with playwright (10% of the time) as well as in the regular application.
It seems related to not quickly loading the application/being able to connect to firebase real-time database.
In playwright it mostly happens with the first test browser instance that connects to the emulator.
ExperimentalForceLongPolling didn't solve it.

@rulamon
Copy link

rulamon commented May 30, 2022

Hi, we've been having this issue for a while as well when connecting to Realtime Database, both in production and locally, and also in the emulator. We use Firestore as well but the issue doesn't seem to occur there.

@DiogoLopes99
Copy link

DiogoLopes99 commented Jun 1, 2022

I am having this issue as well (using Realtime Database)

@Nantris
Copy link

Nantris commented Jun 1, 2022

People who are experiencing this; please do edit to specify whether you're using Realtime Database or Firestore, as both are being discussed in this issue.

@dfrazao
Copy link

dfrazao commented Jun 2, 2022

Hey, I also have been experiencing this issue, particularly while using Realtime Database, locally, in production as well as in the emulator.

@Guilherme27Borges27
Copy link

Hello, I'm getting this issue too and it's on Realtime Database.

@wu-hui
Copy link
Contributor

wu-hui commented Jun 2, 2022

It seems like most people are experiencing this with RTDB except maybe @codescooper ?

@codescooper Can you please confirm which DB you are using?

@Nantris
Copy link

Nantris commented Jun 3, 2022

This is increasingly disruptive for us - preventing us from doing development or testing. The issue is over 90 days old now. Could we get some comment from the Firebase team about what Realtime Database users are supposed to do to remedy this?

I know Realtime Database isn't what Firebase is pushing these days, but we deserve a solution as much as Firestore users.

Object
jsEngine: "hermes"
message: "Error: Client is offline."
stack: "Error: Error: Client is offline.↵    at anonymous ...

And so no work can be done at all.

@fredzqm
Copy link
Contributor

fredzqm commented Jun 6, 2022

@maneesht this would be interested to look into.

@maneesht
Copy link
Contributor

maneesht commented Jun 6, 2022

@slapbox could you enable logging for RTDB?

import { enableLogging } from '@firebase/database';
enableLogging(true);
//initialize firebase

And then can you paste the logs? But please be sure to leave out any project identifying information (URLs, projectIds, etc.)

@Nantris
Copy link

Nantris commented Jun 6, 2022

@maneesht the output looks like this (all logging is from Firebase logging except the line starting with ObjectjsEngine)

Note that this same code worked fine before [email protected].

FIREBASE p:0: Browser went online. 
FIREBASE p:0: Listen called for /users/redacted default 
FIREBASE event: /.info/connected:value:false 
FIREBASE p:0: Making a connection attempt 
FIREBASE p:0: get 0 timed out on connection 
FIREBASE 0: get for query "redacted" failed: Error: Client is offline. 
FIREBASE p:0: Auth token refreshed 
FIREBASE getToken() completed. Creating connection. 
FIREBASE c:0:0: Connection created 
FIREBASE p:0: get 1 timed out on connection 
FIREBASE 0: get for query "redacted" failed: Error: Client is offline. 
ObjectjsEngine: "hermes"message: "Error: Client is offline."stack: "Error: Error: Client is offline.\n    at anonymous (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:521277:38)\n    at tryCallOne (/tmp/hermes/staging/hermes/cmake/intlDebug/x86_64/lib/InternalBytecode/InternalBytecode.js:53:16)\n    at anonymous (/tmp/hermes/staging/hermes/cmake/intlDebug/x86_64/lib/InternalBytecode/InternalBytecode.js:139:27)\n    at apply (native)\n    at anonymous (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:33835:26)\n    at _callTimer (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:33735:17)\n    at _callReactNativeMicrotasksPass (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:33770:17)\n    at callReactNativeMicrotasks (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:33977:44)\n    at __callReactNativeMicrotasks (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:23594:46)\n    at anonymous (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:23373:45)\n    at __guard (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:23577:15)\n    at flushedQueue (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:23372:21)\n    at callFunctionReturnFlushedQueue (http://192.168.1.XX:8081/__generated__/AppEntry.bundle?platform=android&dev=true&minify=false&app=com.redacted.redacted&modulesOnly=false&runModule=true:23354:33)"__proto__: Object
FIREBASE c:0:0:0 Websocket connecting to wss://redacted.firebaseio.com/.ws?v=5 
FIREBASE c:0:0:0 Websocket connected. 
FIREBASE c:0:0: Realtime connection established. 
FIREBASE p:0: connection ready 
FIREBASE p:0: reportStats {"c":{"sdk.js.9-8-2":1,"framework.reactnative":1}} 
FIREBASE p:0: {"r":1,"a":"s","b":{"c":{"sdk.js.9-8-2":1,"framework.reactnative":1}}} 
FIREBASE p:0: {"r":2,"a":"auth","b":{"cred":"eyJhbGciOiJSUzI1NiIsImtpZCI6ImY0ZTc2NDk3ZGE3Y2ZhOWNjMDkwZDcwZTIyNDQ2YTc0YjVjNTBhYTkiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vcmVjb2xsZWN0ci1iODk1ZSIsImF1ZCI6InJlY29sbGVjdHItYjg5NWUiLCJhdXRoX3RpbWUiOjE2NTQ1NDcwMzAsInVzZXJfaWQiOiI3cXluaUd5Y3g3UFNkSDY3OWxlbDduS01vU0gyIiwic3ViIjoiN3F5bmlHeWN4N1BTZEg2NzlsZWw3bktNb1NIMiIsImlhdCI6MTY1NDU0NzAzMCwiZXhwIjoxNjU0NTUwNjMwLCJlbWFpbCI6Im1vYmlsZUBtb2JpbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJmaXJlYmFzZSI6eyJpZGVudGl0aWVzIjp7ImVtYWlsIjpbIm1vYmlsZUBtb2JpbGUuY29tIl19LCJzaWduX2luX3Byb3ZpZGVyIjoicGFzc3dvcmQifX0.aAj2EFrPgrVDRvTiwCljFO2eY06NSD-gTYslQpHJimMcHL1r0ZDyCxlzX_L1GkHDWtyseuH0kLK-LwD4G_6l6xWgVQh4oB12g9uNoH9Npw0gqyIxJURA3gEgMg_ezzhZeaKdOTn1OSX5l_FBoF8wtfK9xTZYlcr5ekTDKUBQP-kcIL7bMelvGkLN9EM12iMp48EZHz6Ig5WG-U_19_-VGTMUXjS7b1hQvRTwdNz33bzyLEicSqtOTtPKWfwPrX1gE8QVh075CdFSkYbNAE6tpIXHigTA9jsNGdV4kMeGg-MsavewWmuL9vUT5Jbi3HBIii9-zONeTglWhUoJcACMaQ"}} 
FIREBASE p:0: Listen on /users/redacted for default 
FIREBASE p:0: {"r":3,"a":"q","b":{"p":"/users/redacted","h":""}} 
FIREBASE event: /.info/connected:value:true 
FIREBASE p:0: from server: {"r":1,"b":{"s":"ok","d":""}} 
FIREBASE c:0:0: Primary connection is healthy. 
FIREBASE p:0: from server: {"r":2,"b":{"s":"ok","d":{"auth":{"email_verified":false,"provider":"password","email":"redacted","user_id":"redacted","token":{"email_verified":false,"email":"redacted","exp":1654550630,"user_id":"redacted","iat":1654547030,"sub":"redacted","aud":"redacted","auth_time":1654547030,"iss":"https://securetoken.google.com/redacted","firebase":{"identities":{"email":["redacted"]},"sign_in_provider":"password"}},"uid":"redacted"},"expires":1654550630}}} 
FIREBASE p:0: handleServerMessage d {"p":"users/redacted","d":{redacted}} 
FIREBASE event: /users/redacted:child_added:{[redacted]} 
FIREBASE p:0: from server: {"r":3,"b":{"s":"ok","d":{}}} 
FIREBASE p:0: listen response {"s":"ok","d":{}} 

@maneesht
Copy link
Contributor

maneesht commented Jun 6, 2022

Looks like an onValue or listener of some sort was created, then you queried the connected status, and then made a get. Are you able to make a minimal repro for me to look at? A GitHub repo with an empty config would make it much easier to understand what is going on here.

@Nantris
Copy link

Nantris commented Jun 6, 2022

I'm very unlikely to be able to find time to make a repro case for this, but I can run this test again with the .info/connected code disabled? Although I know for a fact already that this code failed in the same way before I ever added that listener.

The logic flow is:

  1. .info/connected listener (which I'm planning to remove anyway)
  2. We get all the values at /users/redacted
  3. get of /users/redacted fails with "the client is offline"

So literally all that's happening is that single get, which all of our other Firebase code waits for before running (except the .info/connected listener, which does not throw any errors) - so a simple get is what's failing with the error. It only seems to occur with a debugger connected.

@LanderBeeuwsaert
Copy link

LanderBeeuwsaert commented Jun 7, 2022

I can consistently reproduce it with our (quite large) Angular application by having the application in a local developer server, loading with chrome, and once the initial js files have been downloaded, quickly switch in devtools to network "Slow 3G".
That produces the following error:
image
the index.esm2017 line points to:
image
I've also commented out the calls to '.info/connected' to be sure, and indeed, it continues to happen even without that.

logging with firebase logging on:
[2022-06-07T09:03:41.747Z] @firebase/database: p:0: Browser went online.
index.esm2017.js:78 [2022-06-07T09:03:42.018Z] @firebase/database: p:0: Making a connection attempt
index.js:551 [webpack-dev-server] Live Reloading enabled.
index.js:551 [webpack-dev-server] Disconnected!
index.js:551 [webpack-dev-server] Trying to reconnect...
index.esm2017.js:78 [2022-06-07T09:03:42.447Z] @firebase/database: p:0: Auth token refreshed
index.esm2017.js:78 [2022-06-07T09:03:42.452Z] @firebase/database: getToken() completed. Creating connection.
index.esm2017.js:78 [2022-06-07T09:03:42.454Z] @firebase/database: c:0:0: Connection created
index.esm2017.js:78 [2022-06-07T09:03:45.007Z] @firebase/database: c:0:0:0 Websocket connecting to wss://s-usc1f-nss-2513.firebaseio.com/.ws?v=5&p=redacted
index.esm2017.js:78 [2022-06-07T09:03:45.020Z] @firebase/database: p:0: get 0 timed out on connection
index.esm2017.js:78 [2022-06-07T09:03:45.021Z] @firebase/database: 0: get for query "https://redacted" failed: Error: Client is offline.
core.mjs:6500 ERROR Error: Uncaught (in promise): Error: Error: Client is offline.

For now, how we solve it is to add a timeout of 3 seconds to doing that first get call, which solves like 90% of the issue. Probably the 10% remaining are the instances/browsers with slow internet connection/slow application load time

@maneesht
Copy link
Contributor

maneesht commented Jun 7, 2022

Thank you for the information. I was able to reproduce this. I will be looking into it.

@wneel wneel closed this as completed Jun 27, 2022
maneesht added a commit that referenced this issue Jun 27, 2022
This was referenced Jul 6, 2022
@firebase firebase locked and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.