flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[cloud_firestore] Have snapshots() method emit errors for devs to handle!

Open sentd94 opened this issue 3 years ago • 1 comments

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.

sentd94 avatar Jul 29 '22 12:07 sentd94

Thanks for the report. Treating this as an enhancement.

darshankawar avatar Aug 01 '22 06:08 darshankawar

Hi @sentd94, we have heavily change how the data is passed in Firestore, do you still see this issue?

Lyokone avatar Nov 24 '23 10:11 Lyokone

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!

google-oss-bot avatar Dec 05 '23 02:12 google-oss-bot

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.

google-oss-bot avatar Dec 14 '23 02:12 google-oss-bot