Skip to content

Commit 70f1939

Browse files
committed
store: Reset backoff interval after successful connection.
Fixes: zulip#554 Signed-off-by: Zixuan James Li <[email protected]>
1 parent 1964388 commit 70f1939

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/model/store.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ class UpdateMachine {
750750
}
751751

752752
void poll() async {
753-
final backoffMachine = BackoffMachine();
753+
BackoffMachine? backoffMachine;
754754

755755
while (true) {
756756
if (_debugLoopSignal != null) {
@@ -779,20 +779,21 @@ class UpdateMachine {
779779
'Backing off, then will retry…'));
780780
// TODO tell user if transient polling errors persist
781781
// TODO reset to short backoff eventually
782-
await backoffMachine.wait();
782+
await (backoffMachine ??= BackoffMachine()).wait();
783783
assert(debugLog('… Backoff wait complete, retrying poll.'));
784784
continue;
785785

786786
default:
787787
assert(debugLog('Error polling event queue for $store: $e\n'
788788
'Backing off and retrying even though may be hopeless…'));
789789
// TODO tell user on non-transient error in polling
790-
await backoffMachine.wait();
790+
await (backoffMachine ??= BackoffMachine()).wait();
791791
assert(debugLog('… Backoff wait complete, retrying poll.'));
792792
continue;
793793
}
794794
}
795795

796+
backoffMachine = null;
796797
final events = result.events;
797798
for (final event in events) {
798799
await store.handleEvent(event);

0 commit comments

Comments
 (0)