I have recently started to see this error more and more often and not too sure where I would start looking: FirebaseError: [code=already-exists]: Document already exists. Does anyone know what would cause this? Like some stale client database or connection that maybe attempted a retry? All I am doing is something like this: firestore.collection('locations').add({..}). This is using the Firestore Client SDK and I do not see this from all clients, but just some. The caller of this method is outside of my control as it's being triggered from the device/browser.
Related
I'm attempting to incorporate subroutines in Microsoft Flow, which seems to be done by creating a flow called via HTTP by another Flow per posts online. Creating a simple flow that I can call from Postman works great. The problem occurs when I call it from my main flow.
It wanted an API version, so I set the query api-version to 2016-10-01
Now, when it runs, it gives the error
"code": "DirectApiAuthorizationRequired",
"message": "The request must be authenticated only by Shared Access scheme."
Again, the called flow works fine from Postman. It's when called from Flow that it gives the error. All the steps I see online are for Logic App or other tools. Suggestions?
I discovered that when I was recopying the URL, that I had lost the authentication information has it had been moved to Queries in my REST client, so the code was not actually authenticating. So, if anyone else has this issue, copy the URL from the original source!
I have been scouring the firestore docs and the angularfire2 docs looking for any information regarding how firebase/angularfire handles it's write promises when my progressive web app is offline.
The problem is that all of my promises returned from the batch writes are not being resolved (or rejected), so should I be assuming that all promises made offline will be resolved? If so, am I correct in saying I should rather be handling redirects and success messages before the promise is resolved?
Besides my unresolved firebase promises, the offline mode seems to work well. It correctly changes data in various places throughout many collections and documents, and the changes are displayed correctly in the web app.
Once returning to online mode, the relevant changes are made to the database and my pending promises all seem to get resolved at once.
Is this expected behaviour? And if it is what would the correct way about handling success/error messages and redirects be (if they were previously handled in the promise then and catch)
Firestore promises (and completion handlers on other platforms) indeed resolve/reject when the write operation has been committed/rejected on the server. So what you see is indeed the expected behavior.
It seems restricting that I can only get a snapshot from my database to read data from on data change. Is there something I'm missing about OnDataChange?
What if I want to populate a page with data read dynamically from my database, yet no data is changing in the database? I still need to call OnDataChange?
Firebase's onDataChange fires immediately with a snapshot of the current value in the database and subsequently whenever the data changes.
In fact, the Firebase documentation says this:
This method is triggered once when the listener is attached and again every time the data, including children, changes.
The simple answer is you can't block the User Interface with a long running task such as a database query or network request. At best the user will have an unresponsive application at worst an "application not responding exception" (ANR)crash will happen. That's why it is designed with a listener pattern. I assume this is android we are talking about, however the answer is valid for other platforms. If you are doing this on a background thread yes you could do what you are saying, in theory. I don't think firebase is designed that way.
I'm using firebase's .on() event listener to listen for entries inserted into my database in real time. I've noticed that even when a data insertion is denied, a user subscribed to the ref the data was supposed to be inserted into still gets that piece of data, even though in the database the data is never inserted.
I noticed this while developing the chat module of my web app. Here is a gif of the bug: https://gfycat.com/VariableFrailBasenji
I've set a validation rule on new messages that their length has to be under 200:
"$msg": { ".validate": "newData.val().length < 200"}
So when you see me paste in a bunch of letters, the console says the write gets denied, but the user who had the .on() subscription to that part of the database still got the message, even though it didn't get added to the database.
Anyways, this isn't really a post with a question, just wanted to share this strange bug that could potentially lead to data leakage.
The Firebase SDK uses advanced techniques like latency compensation when you write to the database. This means that before the server has acknowledged a write it goes into an in-memory database cache and optimistically assumes the write will be allowed.
When the server denies the write, it will remove the incorrectly cached data and you should see a corresponding child_removed event.
I'm building a somewhat big application. When changing code the server restart and force refresh on the client.
The client keep his session data, but I seem to lose the Meteor.Collection previously sync data, forcing my user to re-sync everything.
I use 0.5.7(did not see anything in 0.5.8 about that)
Is that the expected behavior or I'm I missing something?
This can be tested by adding something like that at your client start (Assuming Components is your Meteor.Collection)
console.log("Length: ", Components.find().fetch().length);
No, you're not missing anything. The collection data should be re-synced on code pushes. However, if your collection data takes more than a second or two to load in, you should look into trying to send less data to the client by creating finer-grained subscriptions that only send data the client needs at the moment.