flutterfire
flutterfire copied to clipboard
[cloud_firestore] Have snapshots() method emit errors for devs to handle!
Discussed in https://github.com/firebase/flutterfire/discussions/9260
Originally posted by sentd94 July 29, 2022 When listening to realtime updates of a collection, no errors / exceptions are emitted to the stream (for example if the client cannot get a connection to the server):
db
.collection('stuff')
.where("someBool", isEqualTo: false)
.snapshots()
.listen((snap) { ... }, onError: (e) {
//never called...
debugPrint(e.toString());
});
Why is this important?
Sometimes you need to differentiate if a collection currently has no documents OR the internet is down and therefore your snapshot is empty.
Note
For getting data just once using get() method there is a getOptions parameter which you can use to enable error throwing (by passing GetOptions(source: Source.server)). For snapshots() you don't have that option.
Thanks for the report. Treating this as an enhancement.
Hi @sentd94, we have heavily change how the data is passed in Firestore, do you still see this issue?
Hey @sentd94. 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.
@sentd94 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.