Skip to content

Commit 08f8815

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

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) {
@@ -788,8 +790,11 @@ class UpdateMachine {
788790
case Server5xxException() || NetworkException():
789791
assert(debugLog('Transient error polling event queue for $store: $e\n'
790792
'Backing off, then will retry…'));
791-
// TODO tell user if transient polling errors persist
792793
// TODO reset to short backoff eventually
794+
accumlatedTransientFailureCount++;
795+
if (accumlatedTransientFailureCount > transientFailureCountNotifyThreshold) {
796+
reportErrorToUserBriefly('Failed to reach server. Will retry: $e');
797+
}
793798
await backoffMachine.wait();
794799
assert(debugLog('… Backoff wait complete, retrying poll.'));
795800
continue;
@@ -805,6 +810,7 @@ class UpdateMachine {
805810
}
806811

807812
store.isLoading = false;
813+
accumlatedTransientFailureCount = 0;
808814
final events = result.events;
809815
for (final event in events) {
810816
await store.handleEvent(event);

0 commit comments

Comments
 (0)