File tree 4 files changed +38
-67
lines changed
Example/Tests/SpecTests/json
4 files changed +38
-67
lines changed Original file line number Diff line number Diff line change 30
30
}
31
31
}
32
32
},
33
- {
34
- "watchStreamClose" : {
35
- "error" : {
36
- "code" : 14 ,
37
- "message" : " Simulated Backend Error"
38
- },
39
- "runBackoffTimer" : true
40
- }
41
- },
42
33
{
43
34
"watchStreamClose" : {
44
35
"error" : {
125
116
"runBackoffTimer" : true
126
117
}
127
118
},
128
- {
129
- "watchStreamClose" : {
130
- "error" : {
131
- "code" : 14 ,
132
- "message" : " Simulated Backend Error"
133
- },
134
- "runBackoffTimer" : true
135
- }
136
- },
137
119
{
138
120
"watchStreamClose" : {
139
121
"error" : {
209
191
}
210
192
}
211
193
},
212
- {
213
- "watchStreamClose" : {
214
- "error" : {
215
- "code" : 14 ,
216
- "message" : " Simulated Backend Error"
217
- },
218
- "runBackoffTimer" : true
219
- }
220
- },
221
194
{
222
195
"watchStreamClose" : {
223
196
"error" : {
283
256
}
284
257
}
285
258
},
286
- {
287
- "watchStreamClose" : {
288
- "error" : {
289
- "code" : 14 ,
290
- "message" : " Simulated Backend Error"
291
- },
292
- "runBackoffTimer" : true
293
- }
294
- },
295
259
{
296
260
"watchStreamClose" : {
297
261
"error" : {
422
386
}
423
387
}
424
388
},
425
- {
426
- "watchStreamClose" : {
427
- "error" : {
428
- "code" : 14 ,
429
- "message" : " Simulated Backend Error"
430
- },
431
- "runBackoffTimer" : true
432
- }
433
- },
434
389
{
435
390
"watchStreamClose" : {
436
391
"error" : {
669
624
"runBackoffTimer" : true
670
625
}
671
626
},
672
- {
673
- "watchStreamClose" : {
674
- "error" : {
675
- "code" : 14 ,
676
- "message" : " Simulated Backend Error"
677
- },
678
- "runBackoffTimer" : true
679
- }
680
- },
681
627
{
682
628
"watchAck" : [
683
629
2
957
903
}
958
904
}
959
905
},
960
- {
961
- "watchStreamClose" : {
962
- "error" : {
963
- "code" : 14 ,
964
- "message" : " Simulated Backend Error"
965
- },
966
- "runBackoffTimer" : true
967
- }
968
- },
969
906
{
970
907
"watchStreamClose" : {
971
908
"error" : {
Original file line number Diff line number Diff line change 517
517
"message" : " Simulated Backend Error"
518
518
},
519
519
"runBackoffTimer" : true
520
- }
520
+ },
521
+ "expect" : [
522
+ {
523
+ "query" : {
524
+ "path" : " collection" ,
525
+ "filters" : [],
526
+ "orderBys" : []
527
+ },
528
+ "errorCode" : 0 ,
529
+ "fromCache" : true ,
530
+ "hasPendingWrites" : false
531
+ }
532
+ ]
521
533
},
522
534
{
523
535
"watchAck" : [
618
630
},
619
631
"runBackoffTimer" : false
620
632
},
633
+ "expect" : [
634
+ {
635
+ "query" : {
636
+ "path" : " collection" ,
637
+ "filters" : [],
638
+ "orderBys" : []
639
+ },
640
+ "errorCode" : 0 ,
641
+ "fromCache" : true ,
642
+ "hasPendingWrites" : false
643
+ }
644
+ ],
621
645
"stateExpect" : {
622
646
"activeTargets" : {}
623
647
}
Original file line number Diff line number Diff line change 27
27
28
28
// To deal with transient failures, we allow multiple stream attempts before giving up and
29
29
// transitioning from OnlineState Unknown to Offline.
30
- static const int kMaxWatchStreamFailures = 2 ;
30
+ // TODO(mikelehen): This used to be set to 2 as a mitigation for b/66228394. @jdimond thinks that
31
+ // bug is sufficiently fixed so that we can set this back to 1. If that works okay, we could
32
+ // potentially remove this logic entirely.
33
+ static const int kMaxWatchStreamFailures = 1 ;
31
34
32
35
// To deal with stream attempts that don't succeed or fail in a timely manner, we have a
33
36
// timeout for OnlineState to reach Online or Offline. If the timeout is reached, we transition
Original file line number Diff line number Diff line change @@ -252,13 +252,20 @@ - (void)sendWatchRequestWithQueryData:(FSTQueryData *)queryData {
252
252
- (void )stopListeningToTargetID : (TargetId)targetID {
253
253
FSTBoxedTargetID *targetKey = @(targetID);
254
254
FSTQueryData *queryData = self.listenTargets [targetKey];
255
- HARD_ASSERT (queryData, " unlistenToTarget : target not currently watched: %s" , targetKey);
255
+ HARD_ASSERT (queryData, " stopListeningToTargetID : target not currently watched: %s" , targetKey);
256
256
257
257
[self .listenTargets removeObjectForKey: targetKey];
258
258
if ([self isNetworkEnabled ] && [self .watchStream isOpen ]) {
259
259
[self sendUnwatchRequestForTargetID: targetKey];
260
- if ([self .listenTargets count ] == 0 ) {
260
+ }
261
+ if ([self .listenTargets count ] == 0 ) {
262
+ if ([self isNetworkEnabled ] && [self .watchStream isOpen ]) {
261
263
[self .watchStream markIdle ];
264
+ } else {
265
+ // Revert to OnlineState::Unknown if the watch stream is not open and we have no listeners,
266
+ // since without any listens to send we cannot confirm if the stream is healthy and upgrade
267
+ // to OnlineState::Online.
268
+ [self .onlineStateTracker updateState: OnlineState: :Unknown];
262
269
}
263
270
}
264
271
}
You can’t perform that action at this time.
0 commit comments