From 9721432a8ce372244d7436d7b4ed189eb0a46f73 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 20 May 2021 14:52:30 +0200 Subject: [PATCH] remove pending events that failed because of permanent error so they don't get stuck --- src/matrix/room/sending/SendQueue.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/matrix/room/sending/SendQueue.js b/src/matrix/room/sending/SendQueue.js index 4b1088c3..1ec789e7 100644 --- a/src/matrix/room/sending/SendQueue.js +++ b/src/matrix/room/sending/SendQueue.js @@ -63,7 +63,17 @@ export class SendQueue { pendingEvent.setWaiting(); } else { log.catch(err); - pendingEvent.setError(err); + const isPermanentError = err.name === "HomeServerError" && ( + err.statusCode === 400 || // bad request, must be a bug on our end + err.statusCode === 403 || // forbidden + err.statusCode === 404 // not found + ); + if (isPermanentError) { + log.set("remove", true); + await pendingEvent.abort(); + } else { + pendingEvent.setError(err); + } } } });