aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore
diff options
context:
space:
mode:
authorGravatar Michael Lehenbauer <mikelehen@gmail.com>2017-10-26 13:57:26 -0700
committerGravatar GitHub <noreply@github.com>2017-10-26 13:57:26 -0700
commit838ee8021845becf42dbacd7a45dbbce798b6010 (patch)
treed57f9ed69493963125ab71c4ce5b91ea2f2c94f2 /Firestore
parent73c7798f8506460663f4b2a7e3b0085319743b84 (diff)
b/67423356: Exponential backoff on writes should back off until the first successful write (#408)
Port the logic from Android / web to delay backoff reset until the first successful write on the stream.
Diffstat (limited to 'Firestore')
-rw-r--r--Firestore/Source/Remote/FSTDatastore.m8
1 files changed, 5 insertions, 3 deletions
diff --git a/Firestore/Source/Remote/FSTDatastore.m b/Firestore/Source/Remote/FSTDatastore.m
index b788df9..95ee12c 100644
--- a/Firestore/Source/Remote/FSTDatastore.m
+++ b/Firestore/Source/Remote/FSTDatastore.m
@@ -917,9 +917,6 @@ typedef NS_ENUM(NSInteger, FSTStreamState) {
FSTLog(@"FSTWriteStream %p response: %@", (__bridge void *)self, response);
[self.workerDispatchQueue verifyIsCurrentQueue];
- // A successful response means the stream is healthy.
- [self.backoff reset];
-
// Always capture the last stream token.
self.lastStreamToken = response.streamToken;
@@ -929,6 +926,11 @@ typedef NS_ENUM(NSInteger, FSTStreamState) {
[self.delegate writeStreamDidCompleteHandshake];
} else {
+ // A successful first write response means the stream is healthy.
+ // Note that we could consider a successful handshake healthy, however, the write itself
+ // might be causing an error we want to back off from.
+ [self.backoff reset];
+
FSTSnapshotVersion *commitVersion = [_serializer decodedVersion:response.commitTime];
NSMutableArray<GCFSWriteResult *> *protos = response.writeResultsArray;
NSMutableArray<FSTMutationResult *> *results = [NSMutableArray arrayWithCapacity:protos.count];