firebase / firebase/firebase-js-sdk
FR: Add number_of_retries option to set() so that it fails when offline.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### [REQUIRED] Describe your environment
* Operating System version: web chrome
* Firebase SDK version: 4.9.1
* Firebase Product: firestore
### [REQUIRED] Describe the problem
Using firestore on web Javascript, i need to work only if user connected to internet so i didn't enable
persistence. --> firebase.firestore().enablePersistence() ...
if i disconnect the network then add a new item to my DB collection the console show many connection error from firestore but wait until i reconnect and then confirm the success of add operation...
expected behaviour; as i didnt enable the persistence feature the (set or update ) should fire the catch and notify me for connection..
maybe it can be as feature request to add options to wait for reconnect or through error on offline, adding this will provide more control to application if we want to enablePersistence..
```this small javascript
var db = firebase.firestore();
function addOneItem() {
var item = {
description: "more details about item",
name: "orange juice web item",
sellPrice: 10
};
db.collection('item').doc('1-1').set(item)
.then(function() {
console.log("Document successfully written!");
})
.catch(function(error) {
console.error("Error writing document: ", error);
});
}
```
thanks
Contributor guide
Assessment
This issue has not been assessed yet.