flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[cloud_firestore] Throws PlatformException client is offline

Open dhuma1981 opened this issue 6 years ago • 24 comments

Describe the bug

The device is active with active internet connection, I receive the following crash report in sentry sometimes, The bug is not consistent.

cloud_firestore: ^0.13.5

PlatformException: PlatformException(Error performing get, Failed to get document because the client is offline., null)
  File "message_codecs.dart", line 569, in StandardMethodCodec.decodeEnvelope
  File "platform_channel.dart", line 156, in MethodChannel._invokeMethod
  File "<asynchronous suspension>"
  File "platform_channel.dart", line 356, in MethodChannel.invokeMapMethod
  File "<asynchronous suspension>"
  File "method_channel_document_reference.dart", line 56, in MethodChannelDocumentReference.get
  File "<asynchronous suspension>"
  File "document_reference.dart", line 69, in DocumentReference.get
  File "<asynchronous suspension>"
  File "conversation.dart", line 32, in Conversation.getById
  File "<asynchronous suspension>"
  File "unparsed"

Expected behavior It should work properly without throwing an exception.

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.17.0-3.4.pre, on Mac OS X 10.15.4 19E287, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.1)
[✓] Connected device (3 available)

dhuma1981 avatar May 06 '20 01:05 dhuma1981

Hi @dhuma1981 can you please provide your and flutter run --verbose while reproducing exception? Also, to better address the issue, would be helpful if you could post a minimal code sample to reproduce the problem Thank you

TahaTesser avatar May 06 '20 09:05 TahaTesser

@TahaTesser The problem here is I am not able to regenerate the issue in development mode. And I am getting the crash report from sentry.

Here the code snippet which is pointed by the crash log.

static Future<Conversation> getById(String id) async {
    return new Conversation.fromSnapshot(
        await _collectionRef.document(id).get());
  }

dhuma1981 avatar May 07 '20 02:05 dhuma1981

@TahaTesser I was able to regenerate the issue. Here are the steps what happens with my app.

  • Device is not connected to internet
  • I connect the device to internet
  • I receives the push notification from Firebase with id
  • I pass this id to the above mentioned method and it throws the mentioned exception.

dhuma1981 avatar May 19 '20 13:05 dhuma1981

Having the same issue. Some code samples and my explication here: https://github.com/FirebaseExtended/flutterfire/issues/2898

William-cpu avatar Jul 08 '20 12:07 William-cpu

Same issue here, but only on documents from a specific collection. It may be unrelated, but that document gets requested right after authentication is confirmed with FirebaseAuth's onAuthStateChanged, but it's really hard to replicate as it doesn't happen every time.

This specific error message seems to come from this line on the Android Firestore SDK, but I'm not too sure what to make of it; it seems to occur when a snapshot is from the cache, but snapshot.exists() is false. (?)

red42 avatar Jul 08 '20 12:07 red42

Snapshot from cache? What is that? Can it be turned off? Maybe that will fix it.

William-cpu avatar Jul 09 '20 17:07 William-cpu

I'm having the same issue. Any update?

davidgalarza avatar Jul 12 '20 17:07 davidgalarza

This is what I'm using and I'm getting the client is offline error. I also tried with get(source: serverAndCache). But after the phone is off for a few minutes the first few requests generate the error.

FutureBuilder<DocumentSnapshot>(
        future: Firestore.instance
            .collection('content')
            .document(widget.item.documentID)
            .get(source: Source.serverAndCache),
        builder:
            (BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
          List<Widget> children;
          if (snapshot.hasData) {
            children = <Widget>[Expanded(child: _itemBody(snapshot.data))];
          } else if (snapshot.hasError) {
            children = <Widget>[
              Icon(
                Icons.error_outline,
                color: Colors.red,
                size: 60,
              ),
              Padding(
                padding: const EdgeInsets.only(top: 16),
                child: Text('Error: ${snapshot.error}'),
              )
            ];
          } else {
            children = <Widget>[
              SizedBox(
                child: CircularProgressIndicator(),
                width: 60,
                height: 60,
              ),
              const Padding(
                padding: EdgeInsets.only(top: 16),
                child: Text('Awaiting result...'),
              )
            ];
          }
          return Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: children,
            ),
          );
        },
      );

William-cpu avatar Jul 14 '20 10:07 William-cpu

Hey @dhuma1981, are you able to confirm if this is still a problem for you? This seems like a Firebase android sdk issue to me and there have been a number of upgrades since you raised the issue.

russellwheatley avatar Jul 07 '21 10:07 russellwheatley

Hey @dhuma1981. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 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 avatar Jul 16 '21 01:07 google-oss-bot

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

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

google-oss-bot avatar Jul 27 '21 01:07 google-oss-bot

Hey @russellwheatley the bug is still there and it is not loading the data, Kindly reopen the issue.

dhuma1981 avatar Jul 29 '21 12:07 dhuma1981

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

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

google-oss-bot avatar Jul 30 '21 01:07 google-oss-bot

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

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

the issue is still there and not fixed.

dhuma1981 avatar Jul 30 '21 06:07 dhuma1981

Please reopen this issue, as it is not fixed yet and still happening.

dhuma1981 avatar Aug 03 '21 03:08 dhuma1981

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

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

google-oss-bot avatar Aug 04 '21 01:08 google-oss-bot

Hey @dhuma1981. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 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 avatar Aug 13 '21 01:08 google-oss-bot

Hey @dhuma1981. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 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 avatar Aug 24 '21 01:08 google-oss-bot

Hey @dhuma1981. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 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 avatar Sep 01 '21 01:09 google-oss-bot

Hey @dhuma1981. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 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 avatar Sep 10 '21 01:09 google-oss-bot