Why does my realtime stream not update when I add in my security rules? No error is returned and the stream is not triggered.
With security rules like this my stream updates when values change on the server or in the local cache.
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.time < timestamp.date(2025, 12, 14);
}
}
}
With security rules like the following, my stream does not update. However if I use a get
then I do receive updates.
service cloud.firestore {
match /databases/{database}/documents {
match /{collection}/{document} {
allow read, delete: if request.auth.uid == resource.data.author_uid;
allow create: if request.auth.uid == request.resource.data.author_uid;
allow update: if request.auth.uid == request.resource.data.author_uid
&& request.auth.uid == resource.data.author_uid;
}
}
}
Get
var doc = await FirebaseFirestore.instance //
.collection('lists')
.doc(id)
.get();
Stream
_stream = FirebaseFirestore //
.instance
.collection('lists')
.snapshots(includeMetadataChanges: true)
.listen(
(QuerySnapshot snapshot) {
0
I needed to specify the uid in my collection. Otherwise there is no filter, Firestore tries to return all the records in the list and then fails the whole snapshot listen. (unsure why no error was returned though)
_stream = FirebaseFirestore //
.instance
.collection('lists')
.where('author_uid', isEqualTo: FirebaseAuth.instance.currentUser?.uid)
.snapshots(includeMetadataChanges: true)
.listen(
(QuerySnapshot snapshot) {
1