fix: ignore 4xx errors when re-sending the to_device queue

The to_device queue was introduced to ensure integrity if e.g. the
server temporarily failed when attempting to send a to_device message.
If, for whatever reason, the server responds with a 4xx error, though,
then we want to ignore that to_device message from the queue and move on,
as that means that something different was fundamentally wrong. This
helps to fix the to_device queue clogging up, making clients incapable
of sending to_device events anymore, should such clogging happen.
This commit is contained in:
Sorunome 2021-12-08 13:00:53 +01:00
parent 8f877b2039
commit fa5abfca92
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
1 changed files with 7 additions and 1 deletions

View File

@ -2055,7 +2055,13 @@ class Client extends MatrixApi {
(v as Map).map((k, v) => MapEntry<String, Map<String, dynamic>>(
k, Map<String, dynamic>.from(v)))));
await super.sendToDevice(entry.type, entry.txnId, data);
try {
await super.sendToDevice(entry.type, entry.txnId, data);
} on MatrixException catch (e) {
Logs().w(
'[To-Device] failed to to_device message from the queue to the server. Ignoring error: $e');
Logs().w('Payload: $data');
}
await database.deleteFromToDeviceQueue(entry.id);
}
}