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
batch.commit() doesn't work if it's called immediately after firebase.firestore() #2122
Comments
Your code should work fine as is. (It does for me, both as a node.js app, and as a web app.) One thing of note though: You're not waiting on the promise returned by batch.commit(). That might not matter, but if your app exits immediately after returning from onUploadClick(), then you might not see the response. It's a race condition. And you're more likely to win the race if the Firestore initialization is started earlier which might explain why you successfully saw the console.log output in that case. |
It's running in the browser, so there shouldn't be any issue about the app exiting - I should be seeing "Done" in the console. Also, I should be seeing the upload in the network tab and I should be seeing data in my Firestore database, and I'm not seeing any of those things. |
One other possibility: Are you concurrently changing the authenticated user by any chance (incl logging out)? If we queue the batch as one user, but the authenticated user changes by the time we're ready to send the batch, then it'll be dropped. (A debug log could confirm this; see below.) Otherwise, are you able to send over a minimal repro? (Don't forget to remove your apikey, etc before posting it though.) Alternatively/additionally, could you enable debug logging and send the results over? (Hint: |
If this is auth related, then this might be the same issue as #2135 (in which case, a fix is in the works.) Otherwise, see if you can send over a minimal repro and/or debug logs. |
I haven't been able to reproduce it in a minimal app, so I'm closing. |
Environment
Problem
batch.commit() is neither resolved nor rejected when run using the code below. The first message is written to the console but neither of the last two is. I made it work by moving
const db = firebase.firestore()
to a different place, where it would get run on app startup instead of right before the upload happens. I didn't see anything in the docs that says it's required to do that.Relevant Code:
The text was updated successfully, but these errors were encountered: