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)
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 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());
}
@TahaTesser I was able to regenerate the issue. Here are the steps what happens with my app.
Having the same issue. Some code samples and my explication here: https://github.com/FirebaseExtended/flutterfire/issues/2898
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. (?)
Snapshot from cache? What is that? Can it be turned off? Maybe that will fix it.
I'm having the same issue. Any update?
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,
),
);
},
);
Most helpful comment
I'm having the same issue. Any update?