-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Firestore completion handler not called for setData #2167
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
Comments
Could you enable logging and post what you see in the logs? I can't think of any way that reads would work but writes don't work that's related to certificate setup--the connection should be all or nothing. One thing to be careful of: are you sure |
We've updated the Carthage instructions in #2171. |
An assertion will fail if the certificates bundle cannot be loaded, triggering a crash, so it's unlikely that this issue is related to certificates. |
Here is a debug log of the successful getDocuments and a failed setData ran on a real device
|
@wilhuff The read with |
@dbarrett0815 Thanks for the logs! Very helpful. It looks like what's happening is that your write is being queued before you're authenticated to Firebase Authentication and so it's an "unauthenticated" write. And then you authenticate as some user before we get a chance to send the write to the backend, and so we do not send it, because now you're authenticated as a different user. Basically, Firestore keeps a separate write queue per user (aka separate Firebase Authentication UID) and because you can only be authenticated as one user at a time, Firestore only sends writes to the backend for the user you are currently authenticated as. That way the writes aren't incorrectly rejected or accepted due to security rules being applied for a different user. We treat unauthenticated writes as a separate user as well, so they fall into the same category. Once you're authenticated, we don't send them (unless you sign out again). We have an open issue to try to improve this situation somewhat. For instance, in the case of unauthenticated writes, we could spin up a separate unauthenticated stream to the backend and continue sending your unauthenticated writes in the background, even when you are logged in as somebody new. Unfortunately this doesn't generalize to authenticated users, since we can only get authentication tokens for the currently-signed-in user. So it's not a full solution, but it looks like it might solve your case. In your situation, you may be able to workaround the issue by either:
Does this help? |
@mikelehen That seems like that was the issue! I was bypassing the login for testing purposes but when I logged in it worked. Thank you |
Same problem, how do you solve it? |
@JoakoDr If this really is the same problem, then the advice from @mikelehen above is:
However, the way we diagnosed this was specifically this problem was by looking at the logs. If those suggestions don't help (or you're not using Firebase Auth) then please create a new issue describing in detail what you're doing. Ideally share relevant code snippets and the output of logs to help us help you track this down. |
i've successfully signed-in to Firebase, get the user email and the user uid, and then do the setData(), but it doesnt work: func registrarse(user: String, password:String ,delegate: DataHolderDelegate){
Looking for some help, Thanks. |
Solved. Thanks to @albertogurpegui |
Uh oh!
There was an error while loading. Please reload this page.
[READ] Step 1: Are you in the right place?
Yes
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Setting data to firestore using the setData method does not execute closure. Reading from the database works but cannot add new data to the database. I have followed the installation instructions for carthage step by step. The only discrepancy is that the when copying the bundle resources for firestore I copied the gRPCCertificates-Firestore.bundle file from the /Carthage/Build/iOS/FirebaseFirestore.framework/ folder but the readme says to copy gRPCCertificates.bundle(which was not in that folder). I've tried both on a simulator and a real device and have tried different network connections. Database rules allow writes
Steps to reproduce:
Relevant Code:
The text was updated successfully, but these errors were encountered: