As far as I understand, Firestore, by default, works in such a way that if a write is made, but the client is offline, the write is stored locally, then sent to the server once the connection's restored.
It's an undesired behaviour for me, since:
- I've got an app that stores some data.
- Multiple users can update the same data.
- As far as I understand, if user A stores a local write due to network errors, then user B makes some changes, then user A gets his connection back running, then user's A write will overwrite user's B changes.
Therefore, I'd like to completely disable the offline features. If a write directly to the servers could not be completed for whatever reason, I'd like to have an error thrown, or be signaled in any other way, so I can simply inform the user. How do I do that?
My current code:
firestore
.collection("someData")
.doc(props.id)
.set({ contentState: content }, { merge: true })
.catch(x => {
console.log("Error!");
setSyncError(true);
});
The catch func never fires, I assume it's because the buffer-offline-writes capability is enabled by default.