Search code examples
ionic-frameworkgoogle-cloud-firestoreangularfireionic4angularfire5

What is the best way to handle disconnect for Ionic 4/Firebase


I am running and developing an Ionic 4 application but I get plenty of console errors if the enable Disconnect on Chrome developer tools. What is the best way to handle this and stop the error generations?

[Edit] - Some errors

zone.js:3243 POST https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=projects%9e%2Fdatabases%2F(default)&VER=8&gsessionid=zS_Z186jbzIduyA8czPUNKQ3nDUeAStV&SID=6_aGSsvm--uKTRwIw6hLjQ&RID=45854&AID=18&zx=fotdumdzihh5&t=1 net::ERR_INTERNET_DISCONNECTED

zone.js:3243 POST https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=projects%89e%2Fdatabases%2F(default)&VER=8&gsessionid=zS_Z186jbzIduyA8czPUNKQ3nDUeAStV&SID=6_aGSsvm--uKTRwIw6hLjQ&RID=45854&AID=18&zx=6g8tdtpwagpv&t=2 net::ERR_INTERNET_DISCONNECTED

www.google.com/images/cleardot.gif?zx=k0fhnf17yuw:1 GET https://www.google.com/images/cleardot.gif?xxw net::ERR_INTERNET_DISCONNECTED

Solution

  • I had a similar issue with Firebase realtime database, where once the app goes offline there was a console log spam (caused by fb attempting to establish connection), where I had to use .goOffline() method provided by the SDK to prevent it.

    With Firestore SDK there are similar methods:

    Which you could call programmatically in the online/offline network listener callback. If you can share your particular implementation I could help you show how.