Skip to content

Commit

Permalink
Reset backoff when connectivity status changes (#3279)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Jul 8, 2020
1 parent 989cb75 commit 9a9a81f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .changeset/thick-rabbits-guess.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 6 additions & 1 deletion packages/firestore/src/remote/remote_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 9a9a81f

Please sign in to comment.