Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comprehensively retry event-poll failures #1063

Merged
merged 29 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e4982f0
api [nfc]: Mark ServerException sealed
gnprice Nov 15, 2024
442929f
api: Add missing includeToJson flags on some "type"/etc getters
gnprice Nov 10, 2024
92c59ba
store: Add missing return-if-disposed after awaiting backoff
gnprice Nov 1, 2024
31624d5
store [nfc]: Simplify a line to `store.realmUrl`, skipping connection
gnprice Nov 9, 2024
31b7df6
store: Identify realm by realmUrl, not a modified version of it
gnprice Nov 9, 2024
61406ba
log: Fix only case of debugLog outside assert
gnprice Nov 9, 2024
dfefa8a
store [nfc]: Add UpdateMachine.debugPrepareLoopError
gnprice Nov 10, 2024
454f27d
store test [nfc]: Push a bit more into setup for poll tests
gnprice Nov 11, 2024
57852f3
store test [nfc]: Rename logReportedError helper
gnprice Nov 11, 2024
250e3c6
store test [nfc]: Fix test name referring to ZulipApiException
gnprice Nov 10, 2024
c99bb9c
store test [nfc]: Give a logical order to retry-on-failure tests
gnprice Nov 11, 2024
372b882
store test [nfc]: Pull out checkReload, to use for more cases of relo…
gnprice Nov 10, 2024
faa87f5
store test [nfc]: Pull out prepare-error helpers
gnprice Nov 11, 2024
d772b1f
store test: Add remaining test of retry/reload, for SocketException
gnprice Nov 11, 2024
1112d69
store test [nfc]: Pull out helpers checkReported and friends
gnprice Nov 11, 2024
2f83357
store test [nfc]: Put report-error tests in same logical order as ret…
gnprice Nov 11, 2024
23c3174
store test: Test no error reported for expired queue
gnprice Nov 10, 2024
0cf73b9
store test: Fill in remaining cases for report-error tests
gnprice Nov 11, 2024
1bf4422
store [nfc]: Dedupe details of how to report polling failure
gnprice Nov 1, 2024
59609d7
store [nfc]: Dedupe report/retry logic for transient polling errors
gnprice Nov 1, 2024
b28eb28
store [nfc]: Factor out report-and-retry from switch statement
gnprice Nov 8, 2024
2dc6466
store test: Explicitly test rate-limit errors on poll
gnprice Nov 11, 2024
1dfec3d
store: On rate-limit error in poll, explicitly back off and retry
gnprice Nov 8, 2024
2fe1eb3
store [nfc]: Clarify scope of long comment on resetting backoff
gnprice Nov 9, 2024
0d0e576
store [nfc]: Move reload-store logic to enclosing whole poll method
gnprice Nov 9, 2024
61001ca
store test [nfc]: Use async.elapse instead of `await Future.delayed`
gnprice Nov 15, 2024
2595cb0
store: Handle unexpected event-poll errors by reloading store, with b…
gnprice Nov 9, 2024
e82ea7e
store: Better error message on handleEvent failure
gnprice Mar 9, 2024
9e42f26
store: On non-transient request errors, reload rather than retry
gnprice Mar 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@
"error": {"type": "String", "example": "Invalid format"}
}
},
"errorHandlingEventTitle": "Error handling a Zulip event. Retrying connection…",
"@errorHandlingEventTitle": {
"description": "Error title on failing to handle a Zulip server event."
},
"errorHandlingEventDetails": "Error handling a Zulip event from {serverUrl}; will retry.\n\nError: {error}\n\nEvent: {event}",
"@errorHandlingEventDetails": {
"description": "Error details on failing to handle a Zulip server event.",
"placeholders": {
"serverUrl": {"type": "String", "example": "https://chat.example.com"},
"error": {"type": "String", "example": "Unexpected null value"},
"event": {"type": "String", "example": "UpdateMessageEvent(id: 123, messageIds: [2345, 3456], newTopic: 'dinner')"}
}
},
"errorSharingFailed": "Sharing failed",
"@errorSharingFailed": {
"description": "Error message when sharing a message failed."
Expand Down
2 changes: 1 addition & 1 deletion lib/api/exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class NetworkException extends ApiRequestException {
/// This should always represent either some kind of operational issue
/// on the server, or a bug in the server where its responses don't
/// agree with the documented API.
abstract class ServerException extends ApiRequestException {
sealed class ServerException extends ApiRequestException {
final int httpStatus;

/// The response body, decoded as a JSON object.
Expand Down
9 changes: 9 additions & 0 deletions lib/api/model/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ sealed class RealmUserEvent extends Event {
@JsonSerializable(fieldRename: FieldRename.snake)
class RealmUserAddEvent extends RealmUserEvent {
@override
@JsonKey(includeToJson: true)
String get op => 'add';

final User person;
Expand All @@ -231,6 +232,7 @@ class RealmUserAddEvent extends RealmUserEvent {
/// A [RealmUserEvent] with op `remove`: https://zulip.com/api/get-events#realm_user-remove
class RealmUserRemoveEvent extends RealmUserEvent {
@override
@JsonKey(includeToJson: true)
String get op => 'remove';

final int userId;
Expand Down Expand Up @@ -268,6 +270,7 @@ class RealmUserUpdateCustomProfileField {
@JsonSerializable(fieldRename: FieldRename.snake)
class RealmUserUpdateEvent extends RealmUserEvent {
@override
@JsonKey(includeToJson: true)
String get op => 'update';

@JsonKey(readValue: _readFromPerson) final int userId;
Expand Down Expand Up @@ -351,6 +354,7 @@ sealed class ChannelEvent extends Event {
@JsonSerializable(fieldRename: FieldRename.snake)
class ChannelCreateEvent extends ChannelEvent {
@override
@JsonKey(includeToJson: true)
String get op => 'create';

final List<ZulipStream> streams;
Expand All @@ -368,6 +372,7 @@ class ChannelCreateEvent extends ChannelEvent {
@JsonSerializable(fieldRename: FieldRename.snake)
class ChannelDeleteEvent extends ChannelEvent {
@override
@JsonKey(includeToJson: true)
String get op => 'delete';

final List<ZulipStream> streams;
Expand All @@ -385,6 +390,7 @@ class ChannelDeleteEvent extends ChannelEvent {
@JsonSerializable(fieldRename: FieldRename.snake)
class ChannelUpdateEvent extends ChannelEvent {
@override
@JsonKey(includeToJson: true)
String get op => 'update';

final int streamId;
Expand Down Expand Up @@ -666,6 +672,7 @@ class UserTopicEvent extends Event {
// in order to skip the boilerplate in [fromJson] and [toJson].
class MessageEvent extends Event {
@override
@JsonKey(includeToJson: true)
String get type => 'message';

// In the server API, the `flags` field appears directly on the event rather
Expand Down Expand Up @@ -857,6 +864,7 @@ sealed class UpdateMessageFlagsEvent extends Event {
@JsonSerializable(fieldRename: FieldRename.snake)
class UpdateMessageFlagsAddEvent extends UpdateMessageFlagsEvent {
@override
@JsonKey(includeToJson: true)
String get op => 'add';

final bool all;
Expand All @@ -879,6 +887,7 @@ class UpdateMessageFlagsAddEvent extends UpdateMessageFlagsEvent {
@JsonSerializable(fieldRename: FieldRename.snake)
class UpdateMessageFlagsRemoveEvent extends UpdateMessageFlagsEvent {
@override
@JsonKey(includeToJson: true)
String get op => 'remove';

// final bool all; // deprecated, ignore
Expand Down
7 changes: 7 additions & 0 deletions lib/api/model/events.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,18 @@ abstract class ZulipLocalizations {
/// **'Error connecting to Zulip at {serverUrl}. Will retry:\n\n{error}'**
String errorConnectingToServerDetails(String serverUrl, String error);

/// Error title on failing to handle a Zulip server event.
///
/// In en, this message translates to:
/// **'Error handling a Zulip event. Retrying connection…'**
String get errorHandlingEventTitle;

/// Error details on failing to handle a Zulip server event.
///
/// In en, this message translates to:
/// **'Error handling a Zulip event from {serverUrl}; will retry.\n\nError: {error}\n\nEvent: {event}'**
String errorHandlingEventDetails(String serverUrl, String error, String event);

/// Error message when sharing a message failed.
///
/// In en, this message translates to:
Expand Down
8 changes: 8 additions & 0 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
return 'Error connecting to Zulip at $serverUrl. Will retry:\n\n$error';
}

@override
String get errorHandlingEventTitle => 'Error handling a Zulip event. Retrying connection…';

@override
String errorHandlingEventDetails(String serverUrl, String error, String event) {
return 'Error handling a Zulip event from $serverUrl; will retry.\n\nError: $error\n\nEvent: $event';
}

@override
String get errorSharingFailed => 'Sharing failed';

Expand Down
8 changes: 8 additions & 0 deletions lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
return 'Error connecting to Zulip at $serverUrl. Will retry:\n\n$error';
}

@override
String get errorHandlingEventTitle => 'Error handling a Zulip event. Retrying connection…';

@override
String errorHandlingEventDetails(String serverUrl, String error, String event) {
return 'Error handling a Zulip event from $serverUrl; will retry.\n\nError: $error\n\nEvent: $event';
}

@override
String get errorSharingFailed => 'Sharing failed';

Expand Down
8 changes: 8 additions & 0 deletions lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
return 'Error connecting to Zulip at $serverUrl. Will retry:\n\n$error';
}

@override
String get errorHandlingEventTitle => 'Error handling a Zulip event. Retrying connection…';

@override
String errorHandlingEventDetails(String serverUrl, String error, String event) {
return 'Error handling a Zulip event from $serverUrl; will retry.\n\nError: $error\n\nEvent: $event';
}

@override
String get errorSharingFailed => 'Sharing failed';

Expand Down
Loading