firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.86k stars 891 forks source link

firebase/firestore: Firestore (10.12.2): WebChannelConnection RPC 'Write' stream 0x8ad3221f transport errored #8281

Closed GiomScript closed 4 months ago

GiomScript commented 5 months ago

Operating System

ios 17.5.1

Browser Version

Expo

Firebase SDK Version

10.12.2

Firebase SDK Product:

Auth, Database, Firestore, Storage

Describe your project's tooling

React Native with Expo

Describe the problem

I am experiencing a persistent issue with my React Native application that uses Firebase Firestore for data storage and retrieval. The app frequently encounters errors indicating that the client is offline, even though the device has an active internet connection. This problem occurs when attempting to fetch data from Firestore, such as checking if a user is following another user or fetching posts. The errors disrupt the normal functionality of the app and prevent data from being retrieved or displayed correctly.

Here are the specific error messages encountered:

ERROR  Error checking if following: [FirebaseError: Failed to get document because the client is offline.]
ERROR  Error checking if following: [FirebaseError: Failed to get document because the client is offline.]
ERROR  Error checking if following: [FirebaseError: Failed to get document because the client is offline.]
ERROR  Error checking if following: [FirebaseError: Failed to get document because the client is offline.]
ERROR  Error checking if following: [FirebaseError: Failed to get document because the client is offline.]
ERROR  Error checking if following: [FirebaseError: Failed to get document because the client is offline.]
ERROR  Error checking if following: [FirebaseError: Failed to get document because the client is offline.]
ERROR  Error checking if following: [FirebaseError: Failed to get document because the client is offline.]
WARN  [2024-05-31T01:49:52.085Z]  @firebase/firestore: Firestore (10.12.2): WebChannelConnection RPC 'Write' stream 0x8ad32229 transport errored: {"defaultPrevented": false, "g": {"C": undefined, "F": null, "M": [Circular], "g": {"A": null, "Aa": 0, "B": 0, "C": null, "Ca": false, "D": "gsessionid", "Da": [Hc], "F": false, "G": 0, "H": [Object], "I": [T], "J": true, "K": "", "L": undefined, "M": false, "O": true, "P": false, "R": 0, "S": [Object], "T": -1, "Ta": 5000, "U": 52133, "Ua": false, "Va": false, "W": "https://firestore.googleapis.com/google.firestore.v1.Firestore/Write/channel", "Wa": 2, "X": false, "Xa": undefined, "Y": 0, "Ya": 1, "ba": false, "ca": undefined, "cb": 10000, "g": null, "h": [ic], "i": [Array], "ia": null, "j": [vb], "ja": undefined, "ka": null, "l": [Z], "m": null, "o": null, "pa": undefined, "qa": null, "s": null, "u": null, "v": 0, "wa": 600000, "ya": null, "za": -1}, "h": {"database": "projects/alternative-3023b/databases/(default)"}, "i": {"g": [Object], "h": 4, "src": [Circular]}, "j": {"g": [Circular]}, "l": "https://firestore.googleapis.com/google.firestore.v1.Firestore/Write/channel", "s": false, "u": true, "v": true}, "type": "c"}
WARN  [2024-05-31T01:49:59.583Z]  @firebase/firestore: Firestore (10.12.2): WebChannelConnection RPC 'Listen' stream 0x8ad3222a transport errored: {"defaultPrevented": false, "g": {"C": undefined, "F": null, "M": [Circular], "g": {"A": null, "Aa": 0, "B": 0, "C": null, "Ca": false, "D": "gsessionid", "Da": [Hc], "F": false, "G": 0, "H": [Object], "I": [T], "J": true, "K": "", "L": undefined, "M": false, "O": true, "P": false, "R": 0, "S": [Object], "T": -1, "Ta": 5000, "U": 33972, "Ua": false, "Va": false, "W": "https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channelT": -1, "Ta": 50", "Wa": 2, "X": false, "Xa": undefined, "Y": 0, "Ya": 12, "ba": false, "ca": undefined, "cb": 10000, "g": null, "h": [ic], "i": [Array], "ia false, "Xa": un": null, "j": [vb], "ja": undefined, "ka": null, "l": [Z], "m": null, "o": null, "pa": undefined, "qa": null, "s": null, "u": nu "s": null, "u": null, "v": 0, "wa": 600000, "ya": null, "za": -1}, "h": {"database": "projects/alternative-3023b/databases/(default)"}, "i": {"g": [Object], "h": 4, "src": ase": "projects/ [Circular]}, "j": {"g": [Circular]}, "l": "https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel", "s": false, "u": true, "v": true}, "type": "c"}

These errors occur intermittently but often enough to significantly impact the user experience. The app is built using React Native and uses Firebase Firestore for backend services.

Steps and code to reproduce issue

https://gist.github.com/dconeybe/51a2cc3ea9760bd9050ccf138c15475f

dlarocque commented 5 months ago

This looks similar to https://github.com/firebase/firebase-js-sdk/issues/7354

Edit: Nevermind. The error looks similar, but ERROR Error checking if following: [FirebaseError: Failed to get document because the client is offline.] tells me this is a different issue.

GiomScript commented 5 months ago

Hi,It looks similar, but it has never been resolved. Thanks.Best regards,GiorgiOn

dlarocque commented 5 months ago

Hi,It looks similar, but it has never been resolved. Thanks.Best regards,GiorgiOn May 31, 2024, at 12:21 PM, Daniel La Rocque @.> wrote: This looks similar to #7354 —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.>

Hi @GiomScript does the issue occur if experimentalForceLongPolling is set to false?

GiomScript commented 5 months ago

Yes, I have tried all options here true or false, no difference:

export const db = initializeFirestore(app, { experimentalForceLongPolling: true, // useFetchStreams: false, // experimentalAutoDetectLongPolling: false, });

dconeybe commented 5 months ago

Hi @GiomScript. Thanks for the report. I'll take a look next week.

Could you tell me, is this issue 100% reproducible? Are you able to connect to Firestore at all? Or does it just happen sometimes for some requests? Thank you.

GiomScript commented 5 months ago

Hi Denver,I can connect to Firestore, but get disconnected in a couple of seconds. It does fetch the data initially, but disconnects and does not reconnect, says the client is offline.Thanks for taking the time to look into it.

dconeybe commented 5 months ago

Thanks. If you're able, could you enable debug logging by calling setLogLevel('debug'), reproduce, then capture the logs for the entire application? You can post the logs at https://gist.github.com/, and can share them directly with me if you're worried about sharing any secrets.

dconeybe commented 5 months ago

After looking at this issue more, I need some logs from you in order to continue investigation. Please provide full debug logs.

GiomScript commented 5 months ago

Hi,Sorry, I was busy with some other project. I will try to get to it tomorrow. I have not done full debugging before. Do I just put it at the App.js or every point I’m communicating with Firestore?

dconeybe commented 5 months ago

You only need to call it once, at the beginning of your application

GiomScript commented 5 months ago

Hi,I’m having trouble with dependencies that setLogLevel from @optimizely/react-sdk use. I tried other logger libraries and had to build issues on EAS dev builds on all of them. I will continue working on this tomorrow and keep you updated. Thanks for your patience.

dconeybe commented 5 months ago

Would something like this work:

import { setLogLevel as setFirestoreLogLevel } from "firebase/firestore";
setFirestoreLogLevel('debug');
GiomScript commented 5 months ago

[edited by @dconeybe] I moved the logs to https://gist.github.com/dconeybe/cfeb5f7384d6b29ef5ba42248af67dfb to keep this issue easy to scroll trough.

dconeybe commented 5 months ago

I see 2 occurrences of this in the logs:

LOG [2024-06-07T16:53:52.284Z] @firebase/firestore: Firestore (10.12.2):WebChannelConnection RPC 'BatchGetDocuments' 0x29424ef2 failed with status:0 response text:The operation couldn’t be completed. No space left on device

It looks like your app may have exhausted its disk space allocation. The error of "'Listen' stream 0x8ad3222a transport errored" is pretty misleading in this case. Could you double-check this?

GiomScript commented 5 months ago

[edited by @dconeybe] I moved the logs to https://gist.github.com/dconeybe/3a59f138e2c16b3a4b060cd87558eacf to keep this issue easy to scroll trough.

dconeybe commented 5 months ago

@GiomScript Thanks for the updated logs. I'm investigating them with a team mate.

I have one question though: Do you documents include any non-ASCII characters in their names of contents? I'm asking because we recently fixed a bug related to UTF-8 encoding of characters that require more than one byte being split across internal buffer boundaries, which should be fixed in this version.

GiomScript commented 5 months ago

Thanks for your help!I don’t think that’s the case. Documents are videos and images uploaded from iPhones. Please let me know if you have any questions.

dconeybe commented 5 months ago

How large are the videos and images? Note that Firestore documents have a maximum size of 1 MiB (1,048,576 bytes).

See https://firebase.google.com/docs/firestore/quotas

To store large files, consider using Cloud Storage for Firebase instead, as that is its intended use case: https://firebase.google.com/docs/storage

GiomScript commented 5 months ago

 Files are uploaded to the Firebase storage and file paths are uploaded to the Firestone. Files are compressed before upload.I had no issues, the problem just started couple weeks ago and it has gotten worse lately. 

dconeybe commented 5 months ago

Hmm ok. Could you try to create a minimal application that can be used to reproduce the problem? That would really help narrow down the investigation.

GiomScript commented 5 months ago

I just started testing the app in Apple TestFlight, and so far it’s performing fine. Let me see if it is my local development setup that’s causing this problem. I will let you know how it goes in the next week. Again, thanks for your help. Have a great weekend!

google-oss-bot commented 5 months ago

Hey @GiomScript. 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!

google-oss-bot commented 4 months ago

Since there haven't been any recent updates here, I am going to close this issue.

@GiomScript if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

pavellyapin commented 3 months ago

I faced this issue, it turned our when I created firestore I didn't choose the (default) name, instead I gave it a custom name. That was a mistake