-
Notifications
You must be signed in to change notification settings - Fork 993
Description
[REQUIRED] Describe your environment
- Operating System version: Android 7.1.1
- Android SDK: 26.0.2
- Browser version: Chrome
- Firebase SDK version: 4.12.1
- Firebase Product: Firestore
- Ionic version: 3.19.1
- Ionic Angular version: 3.9.2
- Cordova Android: 6.4.0
- AngularFire version: 5.0.0-rc.5-next
[REQUIRED] Describe the problem
Cordova Ionic app running Firestore JS fails to recover connection when returning form background.
The console shows retries of attempts to re-establish connection.
Only restarting the app resolves the problem.
This problem started a week ago after starting testing app on Android 7.1.1.
The test used to run on Android 6.0 without any problems with the same version of all packages.
Steps to reproduce:
Open Cordova Android app running Angular+Firebase and do email authorization
Move app to the background (pressing the Android home button)
Wait a few minuts
Reopen the app (we are still logged in)
Open an angular page that uses Firestore api to retrieve a document
e.g.:
firebase.firestore().collection("profiles").doc(profileId).get()
The console shows multiple errors:
{code: "auth/network-request-failed", message: "A network error (such as timeout, interrupted connection or unreachable host) has occurred."}
vendor.js:1 ERROR Error: Uncaught (in promise): FirebaseError: [code=aborted]: Failed to get document because the client is offline.
FirebaseError: Failed to get document because the client is offline.
ERROR Error: Uncaught (in promise): FirebaseError: [code=aborted]: Failed to get document because the client is offline.
FirebaseError: Failed to get document because the client is offline.
And fails to re-establish connection to Firestore:
vendor.js:1 ERROR nn
(anonymous) @ vendor.js:1
vendor.js:1 ERROR nn
(anonymous) @ vendor.js:1
vendor.js:1 ERROR nn
(anonymous) @ vendor.js:1
vendor.js:1 ERROR nn
(anonymous) @ vendor.js:1
vendor.js:1 ERROR nn
When turning on the log at debug level:
firebase.firestore().setLogLevel('debug')
We get some more information:
vendor.js:1 [2018-07-28T09:36:40.634Z] @firebase/firestore: Firestore (4.10.1) [PersistentStream]: close with error: FirebaseError: [code=unknown]: Fetching auth token failed: A network error (such as timeout, interrupted connection or unreachable host) has occurred.
vendor.js:1 [2018-07-28T09:36:40.636Z] @firebase/firestore: Firestore (4.10.1) [ExponentialBackoff]: Backing off for 2212.7402860971715 ms (base delay: 1500 ms)
...
vendor.js:1 [2018-07-28T09:37:43.017Z] @firebase/firestore: Firestore (4.10.1) [PersistentStream]: close with error: FirebaseError: [code=unknown]: Fetching auth token failed: A network error (such as timeout, interrupted connection or unreachable host) has occurred.
vendor.js:1 [2018-07-28T09:37:43.018Z] @firebase/firestore: Firestore (4.10.1) [ExponentialBackoff]: Backing off for 1865.6266004521462 ms (base delay: 2250 ms)
vendor.js:1 ERROR nn
...
vendor.js:1 [2018-07-28T09:39:52.641Z] @firebase/firestore: Firestore (4.10.1) [PersistentStream]: close with error: FirebaseError: [code=unknown]: Fetching auth token failed: A network error (such as timeout, interrupted connection or unreachable host) has occurred.
vendor.js:1 [2018-07-28T09:39:52.644Z] @firebase/firestore: Firestore (4.10.1) [ExponentialBackoff]: Backing off for 3589.0911531043184 ms (base delay: 5062.5 ms)
vendor.js:1 ERROR nn
...
vendor.js:1 [2018-07-28T09:43:24.775Z] @firebase/firestore: Firestore (4.10.1) [Connection]: Creating WebChannel: https://firestore.googleapis.com/google.firestore.v1beta1.Firestore/Listen/channel [object Object]
vendor.js:1 [2018-07-28T09:43:25.632Z] @firebase/firestore: Firestore (4.10.1) [Connection]: Opening WebChannel transport.
vendor.js:1 [2018-07-28T09:43:25.634Z] @firebase/firestore: Firestore (4.10.1) [Connection]: WebChannel sending: {"database":"projects/xxx/(default)","addTarget":{"documents":{"documents":["projects/xxx/(default)/documents/profilesBadges/jRpVDzeqilsxbFRrCLBX"]},"targetId":16,"resumeToken":"CgkI0f6y0r7B3AI="}}
vendor.js:1 [2018-07-28T09:44:12.635Z] @firebase/firestore: Firestore (4.10.1) [Connection]: WebChannel transport errored: Te
vendor.js:1 [2018-07-28T09:44:12.635Z] @firebase/firestore: Firestore (4.10.1) [PersistentStream]: close with error: FirebaseError: [code=unavailable]: The operation could not be completed
...
vendor.js:1 [2018-07-28T09:56:15.635Z] @firebase/firestore: Firestore (4.10.1) [Connection]: WebChannel transport errored: Te
vendor.js:1 [2018-07-28T09:56:15.636Z] @firebase/firestore: Firestore (4.10.1) [PersistentStream]: close with error: FirebaseError: [code=unavailable]: The operation could not be completed
vendor.js:1 [2018-07-28T09:56:15.637Z] @firebase/firestore: Firestore (4.10.1) [ExponentialBackoff]: Backing off for 64064.01037516744 ms (base delay: 60000 ms)
www.google.com/images/cleardot.gif?zx=dzwv0lyag6eu:1 Failed to load resource: net::ERR_CONNECTION_TIMED_OUT
...
After restarting the app everything continues to work,
** While the console shows the errors, the app manages to make other RETS api calls via the network - there is a working internet connection **