Skip to content

Commit fa29128

Browse files
PIG208gnprice
authored andcommitted
store: Reset backoff interval after successful connection.
Fixes: #554 Signed-off-by: Zixuan James Li <[email protected]>
1 parent 1fb76ac commit fa29128

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
@@ -763,7 +763,7 @@ class UpdateMachine {
763763
}
764764

765765
void poll() async {
766-
final backoffMachine = BackoffMachine();
766+
BackoffMachine? backoffMachine;
767767

768768
while (true) {
769769
if (_debugLoopSignal != null) {
@@ -793,20 +793,21 @@ class UpdateMachine {
793793
'Backing off, then will retry…'));
794794
// TODO tell user if transient polling errors persist
795795
// TODO reset to short backoff eventually
796-
await backoffMachine.wait();
796+
await (backoffMachine ??= BackoffMachine()).wait();
797797
assert(debugLog('… Backoff wait complete, retrying poll.'));
798798
continue;
799799

800800
default:
801801
assert(debugLog('Error polling event queue for $store: $e\n'
802802
'Backing off and retrying even though may be hopeless…'));
803803
// TODO tell user on non-transient error in polling
804-
await backoffMachine.wait();
804+
await (backoffMachine ??= BackoffMachine()).wait();
805805
assert(debugLog('… Backoff wait complete, retrying poll.'));
806806
continue;
807807
}
808808
}
809809

810+
backoffMachine = null;
810811
store.isLoading = false;
811812
final events = result.events;
812813
for (final event in events) {

0 commit comments

Comments
 (0)