Does firestore rules validate every time when listener added?

21 Views Asked by At

This is the question previously i asked Questions about firestore cache and reads charge

Basically it says if i add same listener like below twice, I only get charge as single listener for receiving data.

db.collection("testCollection").onSnapshot(function(doc) {}); 
db.collection("testCollection").onSnapshot(function(doc) {});

But if I using get in rules on that path

match /testCollection/{documentId} {
   allow list: get(/databases/$(database)/documents/users/$(request.auth.uid)).data.isAllowToReadTestCollection;
}

Will the rules validate twice? Will I get charged for that get in rules twice?

1

There are 1 best solutions below

0
Frank van Puffelen On BEST ANSWER

Same as in the linked answer - since the listeners get deduped on the client before reaching the server, there should also only be a single evaluation of the security rules.