Skip to content

Commit a7a6e66

Browse files
committed
store: Report if transient polling errors persist.
Signed-off-by: Zixuan James Li <[email protected]>
1 parent dd84e44 commit a7a6e66

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/model/store.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,8 @@ class UpdateMachine {
760760

761761
void poll() async {
762762
final backoffMachine = BackoffMachine();
763+
int accumlatedTransientFailureCount = 0;
764+
const transientFailureCountNotifyThreshold = 10;
763765

764766
while (true) {
765767
if (_debugLoopSignal != null) {
@@ -787,8 +789,11 @@ class UpdateMachine {
787789
case Server5xxException() || NetworkException():
788790
assert(debugLog('Transient error polling event queue for $store: $e\n'
789791
'Backing off, then will retry…'));
790-
// TODO tell user if transient polling errors persist
791792
// TODO reset to short backoff eventually
793+
accumlatedTransientFailureCount++;
794+
if (accumlatedTransientFailureCount > transientFailureCountNotifyThreshold) {
795+
reportErrorToUserBriefly('Failed to reach server. Will retry: $e');
796+
}
792797
await backoffMachine.wait();
793798
assert(debugLog('… Backoff wait complete, retrying poll.'));
794799
continue;
@@ -804,6 +809,7 @@ class UpdateMachine {
804809
}
805810

806811
store.isLoading = false;
812+
accumlatedTransientFailureCount = 0;
807813
final events = result.events;
808814
for (final event in events) {
809815
await store.handleEvent(event);

0 commit comments

Comments
 (0)