Closed
Description
- Xcode version: 9.2
- Firebase SDK version: 4.9.0 (also appears to be a problem for 4.8.0)
- Firebase Component: Firestore
- Component version: 0.10.1 (also appears to be a problem for 0.9.4)
Steps to reproduce:
When multiple "Missing or insufficient permissions" errors occur in quick succession, the client stops successfully writing to Firestore, and apparently stops trying to.
I'll provide specific code later, but the outline is:
- Set up rules with a collection that can't be written to, foo, and a collection that can be written to, bar.
- Write something to "bar" to confirm you can.
- In a loop, write something to "foo" three times.
- Confirm you can no longer write to "bar", or even get a callback with an error from attempting to write to "foo".
Relevant Code:
Firestore rules:
service cloud.firestore {
match /databases/{database}/documents {
match /bar/{id} {
allow read, write: if true;
}
match /foo/{id} {
allow read, write: if false;
}
}
}
Code:
- Take quickstart-ios's firestore "FriendlyEats" quickstart.
- Replace the following two functions in RestaurantsTableViewController as follows:
@IBAction func didTapPopulateButton(_ sender: Any) {
NSLog("Populate tapped")
let uid = Auth.auth().currentUser!.uid
Firestore.firestore().collection("bar").document().setData(["a": 5]) {
NSLog("bar result: \($0)")
}
}
@IBAction func didTapFilterButton(_ sender: Any) {
NSLog("Filter button tapped")
for _ in [1, 2, 3] {
Firestore.firestore().collection("foo").document().setData(["a": 5]) {
NSLog("foo result: \($0?.localizedDescription)")
}
}
}
- In AppDelegate, optionally add some or all of:
Firestore.enableLogging(true)
let settings = FirestoreSettings()
settings.isPersistenceEnabled = false
Firestore.firestore().settings = settings
This bug appears to be independent of whether offline persistence is enabled.
-
Start the app, and log in.
-
Click "populate" and check your database to confirm that something was written in the "bar" collection.
-
Click "filter" and confirm that you get a bunch of "Missing or insufficient permissions" errors.
-
Click "populate" and "filter" and confirm that you don't get any more callbacks or any database writes; just "X button tapped" log messages.