From 9f0eb36b7257e76b27f4ce0fa1df9f8fdd974db7 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Wed, 24 Jun 2020 15:51:36 -0700 Subject: [PATCH 1/3] Reset backoff when connectivity status changes Port of https://github.com/firebase/firebase-android-sdk/pull/1706 --- packages/firestore/CHANGELOG.md | 3 +++ packages/firestore/src/remote/remote_store.ts | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/firestore/CHANGELOG.md b/packages/firestore/CHANGELOG.md index c9aa89edfdb..0a49da66477 100644 --- a/packages/firestore/CHANGELOG.md +++ b/packages/firestore/CHANGELOG.md @@ -1,4 +1,7 @@ # Unreleased +- [fixed] Removed a delay that may have prevented Firestore from immediately + reestablishing a network connection if a connectivity change occurred while + the app was in the background. - [fixed] Fixed an issue that may have prevented the client from connecting to the backend immediately after a user signed in. diff --git a/packages/firestore/src/remote/remote_store.ts b/packages/firestore/src/remote/remote_store.ts index 599c71403bc..017fb552ecc 100644 --- a/packages/firestore/src/remote/remote_store.ts +++ b/packages/firestore/src/remote/remote_store.ts @@ -153,8 +153,11 @@ export class RemoteStore implements TargetMetadataProvider { connectivityMonitor: ConnectivityMonitor ) { this.connectivityMonitor = connectivityMonitor; - this.connectivityMonitor.addCallback((status: NetworkStatus) => { + this.connectivityMonitor.addCallback((_: NetworkStatus) => { asyncQueue.enqueueAndForget(async () => { + // Porting Note: Unlike iOS, `restartNetwork()` is called even when the + // network becomes unreachable as we don't have any other way to tear + // down our streams. if (this.canUseNetwork()) { logDebug( LOG_TAG, @@ -761,6 +764,8 @@ export class RemoteStore implements TargetMetadataProvider { this.offlineCauses.add(OfflineCause.ConnectivityChange); await this.disableNetworkInternal(); this.onlineStateTracker.set(OnlineState.Unknown); + this.writeStream.inhibitBackoff(); + this.watchStream.inhibitBackoff(); this.offlineCauses.delete(OfflineCause.ConnectivityChange); await this.enableNetworkInternal(); } From 9b8d3a74d127b3b015c559d3e832d6cfad7f1c13 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 7 Jul 2020 13:46:33 -0700 Subject: [PATCH 2/3] Update CHANGELOG.md --- packages/firestore/CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/firestore/CHANGELOG.md b/packages/firestore/CHANGELOG.md index 0a49da66477..c9aa89edfdb 100644 --- a/packages/firestore/CHANGELOG.md +++ b/packages/firestore/CHANGELOG.md @@ -1,7 +1,4 @@ # Unreleased -- [fixed] Removed a delay that may have prevented Firestore from immediately - reestablishing a network connection if a connectivity change occurred while - the app was in the background. - [fixed] Fixed an issue that may have prevented the client from connecting to the backend immediately after a user signed in. From 0ed3a53011f3d8f53525650c5ea66706a1970d3e Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 7 Jul 2020 13:47:57 -0700 Subject: [PATCH 3/3] Create thick-rabbits-guess.md --- .changeset/thick-rabbits-guess.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/thick-rabbits-guess.md diff --git a/.changeset/thick-rabbits-guess.md b/.changeset/thick-rabbits-guess.md new file mode 100644 index 00000000000..ce1c98bc893 --- /dev/null +++ b/.changeset/thick-rabbits-guess.md @@ -0,0 +1,8 @@ +--- +"firebase": patch +"@firebase/firestore": patch +--- + +[fixed] Removed a delay that may have prevented Firestore from immediately +reestablishing a network connection if a connectivity change occurred while +the app was in the background.