Issue : Currently when I log out in the application, the following error is logged in the browser console,
core.es5.js:1020 ERROR Error: permission_denied at /all-posts: Client doesn't have permission to access the desired data.
at Object.webpackJsonp.../../../../@firebase/database/dist/cjs/src/core/util/util.js.exports.errorForServerCode (util.js:513)
at onComplete (SyncTree.js:538)
at Object.onComplete (Repo.js:115)
at PersistentConnection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/core/PersistentConnection.js.PersistentConnection.onListenRevoked_ (PersistentConnection.js:692)
at PersistentConnection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/core/PersistentConnection.js.PersistentConnection.onDataPush_ (PersistentConnection.js:464)
at PersistentConnection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/core/PersistentConnection.js.PersistentConnection.onDataMessage_ (PersistentConnection.js:452)
at Connection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/realtime/Connection.js.Connection.onDataMessage_ (Connection.js:262)
at Connection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/realtime/Connection.js.Connection.onPrimaryMessageReceived_ (Connection.js:256)
at WebSocketConnection.onMessage (Connection.js:157)
at WebSocketConnection.webpackJsonp.../../../../@firebase/database/dist/cjs/src/realtime/WebSocketConnection.js.WebSocketConnection.appendFrame_ (WebSocketConnection.js:197)
There are other similar errors related to permission are logged in the console, this is just for sample.
Here is snapshot.
I am trying to figure out if there is a way to prevent logging these type of errors in the browser console programmatically.
Here's my current code for logout :
logout() {
this.afAuth.auth.signOut()
.then( () => {
this.router.navigate(['login']);
});
}
It looks like you have listeners on a Firebase Database that require the user to be authenticated. When you sign the user out, those listeners become illegal, so the Firebase Database cancels them and tells your app about the error.
To prevent this, stop the listeners before signing the user out by calling ref.off() for each of them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With