Closed thokkane closed 4 years ago
Hi, you forgot the parameter of the openDBChannel action.
Hi @thokkane!
Since set
action is queued in a batch it will depend if the permission error is thrown by Firestore SDK on the firestore.batch().commit()
action.
If a batch has an error, I do make sure that every action's promise called within that batch will be rejected with the error:
Are you not seeing an error when you should?
As for the other issue, please hold on.
Hello again, I'm sorry for my previous wrong answer.
You are right, in the docs it should have been streaming.then(...)
and not streaming().then(...)
. You need to remove the parentheses. We'll update the docs.
Could you please let me know if it fixes the streaming
error for you?
Thank you very much for the report.
@louisameline ok. No longer receiving the error for streaming.
@mesqueeb no, im not able to catch the error with the above code. I tried this with firebase own set function and there i'm able to catch the error.
firebase.database().ref('accounts/'+ id).set({name}, function(error) {
if (error) {
console.log(error.message)
} else {
console.log("DATA SAVED")
}
});
I have firebase 7.14.2
@thokkane Can you try with Firebase's batch
commit?
You need to modify the below example to your use case:
// Get a new write batch
var batch = db.batch();
// Set the value of 'NYC'
var nycRef = db.collection("cities").doc("NYC");
batch.set(nycRef, {name: "New York City"});
// Update the population of 'SF'
var sfRef = db.collection("cities").doc("SF");
batch.update(sfRef, {"population": 1000000});
// Delete the city 'LA'
var laRef = db.collection("cities").doc("LA");
batch.delete(laRef);
// Commit the batch
batch.commit().then(function () {
// ...
}).catch(console.error);
from the docs: https://firebase.google.com/docs/firestore/manage-data/transactions#batched-writes
If this doesn't throw the error, the problem is with Firebase SDK batch function, and you'd have to report it in the firebase SDK JS client repo.
If this does throw the error, then it's a problem with vuex-easy-firestore.
@mesqueeb it seems this was related to the previous issue i logged for having in sync and serverchange "updateStore(doc)" and not "return updateStore(doc)". Modified all the modules with return updateStore(doc) and now i'm able to catch the error and inform the user.
However, I do see that in the console, the error is still shown (not via my console.log). Is there a way to turn off those errors generated by vuex easy firestore?
So the error is produced by this function
/**
* execute Error() based on an error id string
*
* @export
* @param {string} errorId the error id
* @param {any} [error] an actual error from an async request or something
* @returns {string} the error id
*/
function error (errorId, error) {
var logData = errorMessages[errorId] || errorId;
console.error("[vuex-easy-firestore] Error! " + logData);
if (error)
console.error(error);
return errorId;
}
index.esm.js?34ed:211 FirebaseError: Missing or insufficient permissions. at new n (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:160:23) at eval (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:14912:34) at Y.eval (webpack-internal:///./node_modules/@firebase/firestore/dist/index.cjs.js:14867:21) at nb (webpack-internal:///./node_modules/@firebase/webchannel-wrapper/dist/index.esm.js:27:195) at Y.g.dispatchEvent (webpack-internal:///./node_modules/@firebase/webchannel-wrapper/dist/index.esm.js:25:305) at Z.ua (webpack-internal:///./node_modules/@firebase/webchannel-wrapper/dist/index.esm.js:78:35) at Ad.g.Fa (webpack-internal:///./node_modules/@firebase/webchannel-wrapper/dist/index.esm.js:69:204) at ic (webpack-internal:///./node_modules/@firebase/webchannel-wrapper/dist/index.esm.js:33:371) at kc (webpack-internal:///./node_modules/@firebase/webchannel-wrapper/dist/index.esm.js:31:354) at M.g.Ja (webpack-internal:///./node_modules/@firebase/webchannel-wrapper/dist/index.esm.js:30:438)
@thokkane it's currently not possible to turn off certain errors from being logged, and this is one of them.
I reviewed the way errors are logged in v2.0, and will make it possible to turn off all error logging.
Is it breaking for your case that these errors are being logged?
@mesqueeb no its not breaking. Thanks for making these optional in the next version!
The catch error is not working. I just get "Uncaught (in promise) FirebaseError: Missing or insufficient permissions." This not from the below console.log(error) statement.
Is it possible to catch permission errors with the vuex-easy-firestore error handling?
Also in openDBChannel, i'm getting "streaming is not a function" when i have the following. Is there a bug or have i misunderstood?