Skip to content

Commit 1dfec3d

Browse files
committed
store: On rate-limit error in poll, explicitly back off and retry
This covers a particular case of #946. This commit is actually NFC as far as the interaction with the server goes; its only change in behavior is that we treat the error as "expected", and therefore skip reporting it to the user unless it follows a string of other errors. But then this also sets us up so that these rate-limit errors will continue to be handled with backoff-retry when we change the handling of unexpected errors, coming next.
1 parent 2dc6466 commit 1dfec3d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/model/store.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,13 @@ class UpdateMachine {
10541054
isUnexpected = false;
10551055
shouldReportToUser = true;
10561056

1057+
case ServerException(httpStatus: 429):
1058+
case ZulipApiException(httpStatus: 429):
1059+
case ZulipApiException(code: 'RATE_LIMIT_HIT'):
1060+
// TODO(#946) handle rate-limit errors more generally, in ApiConnection
1061+
isUnexpected = false;
1062+
shouldReportToUser = true;
1063+
10571064
default:
10581065
isUnexpected = true;
10591066
shouldReportToUser = true;

test/model/store_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -919,19 +919,19 @@ void main() {
919919
});
920920

921921
test('report rate limit: code RATE_LIMIT_HIT', () {
922-
checkReported(prepareRateLimitExceptionCode).startsWith(
922+
checkLateReported(prepareRateLimitExceptionCode).startsWith(
923923
"Error connecting to Zulip. Retrying…\n"
924924
"Error connecting to Zulip at");
925925
});
926926

927927
test('report rate limit: status 429 ZulipApiException', () {
928-
checkReported(prepareRateLimitExceptionStatus).startsWith(
928+
checkLateReported(prepareRateLimitExceptionStatus).startsWith(
929929
"Error connecting to Zulip. Retrying…\n"
930930
"Error connecting to Zulip at");
931931
});
932932

933933
test('report rate limit: status 429 MalformedServerResponseException', () {
934-
checkReported(prepareRateLimitExceptionMalformed).startsWith(
934+
checkLateReported(prepareRateLimitExceptionMalformed).startsWith(
935935
"Error connecting to Zulip. Retrying…\n"
936936
"Error connecting to Zulip at");
937937
});

0 commit comments

Comments
 (0)