-
Notifications
You must be signed in to change notification settings - Fork 596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Firestore] Security rules return permission denied when reading immediately after writing new document #185
Comments
@SUPERCILEX Can you try waiting for the set to complete before calling get()? E.g.: What may be happening is that the get() is reaching the server before the set() has completed and so the document doesn't exist yet, and your rules don't permit reading nonexistent documents, so the get() fails. Once the set() completes, then you can read it. |
@mikelehen I'm sure that would work, but that callback won't be triggered if I'm offline.
|
Sorry I don't have a better answer. |
This made me see a bug in our docs: It says that |
@samtstern Yeah, I was confused by that. Thanks! ❤️
|
@SUPERCILEX Thanks! Your use case mostly makes sense to me, but I have a couple thoughts:
Can you elaborate on 3? I'm not quite clear on what happened and what you were expecting. Are you saying you believe there's a bug with security rules or something? |
|
Now that you mention it ... |
@samtstern Being able to read a nonexistent document means your read will succeed with a snapshot with |
|
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Suppose I'm writing this document:
With these security rules:
And this code:
ref.set(obj) ref.get() // This fails!
The get request will fail with a
PERMISSION_DENIED
error. But it works fine if I wait a few seconds.The text was updated successfully, but these errors were encountered: