[cloud_firestore] Throws PlatformException client is offline
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.
- 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.
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,
),
);
},
);
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.
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!
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.
Hey @russellwheatley the bug is still there and it is not loading the data, Kindly reopen the issue.
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.
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.
Please reopen this issue, as it is not fixed yet and still happening.
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.
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!
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!
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!
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!