Skip to content

Commit 9f0eb36

Browse files
Reset backoff when connectivity status changes
Port of firebase/firebase-android-sdk#1706
1 parent 8846f61 commit 9f0eb36

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/firestore/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Unreleased
2+
- [fixed] Removed a delay that may have prevented Firestore from immediately
3+
reestablishing a network connection if a connectivity change occurred while
4+
the app was in the background.
25
- [fixed] Fixed an issue that may have prevented the client from connecting
36
to the backend immediately after a user signed in.
47

packages/firestore/src/remote/remote_store.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,11 @@ export class RemoteStore implements TargetMetadataProvider {
153153
connectivityMonitor: ConnectivityMonitor
154154
) {
155155
this.connectivityMonitor = connectivityMonitor;
156-
this.connectivityMonitor.addCallback((status: NetworkStatus) => {
156+
this.connectivityMonitor.addCallback((_: NetworkStatus) => {
157157
asyncQueue.enqueueAndForget(async () => {
158+
// Porting Note: Unlike iOS, `restartNetwork()` is called even when the
159+
// network becomes unreachable as we don't have any other way to tear
160+
// down our streams.
158161
if (this.canUseNetwork()) {
159162
logDebug(
160163
LOG_TAG,
@@ -761,6 +764,8 @@ export class RemoteStore implements TargetMetadataProvider {
761764
this.offlineCauses.add(OfflineCause.ConnectivityChange);
762765
await this.disableNetworkInternal();
763766
this.onlineStateTracker.set(OnlineState.Unknown);
767+
this.writeStream.inhibitBackoff();
768+
this.watchStream.inhibitBackoff();
764769
this.offlineCauses.delete(OfflineCause.ConnectivityChange);
765770
await this.enableNetworkInternal();
766771
}

0 commit comments

Comments
 (0)