From 8b16d8bc99cb2795091e8648716a9b5eedf3fa03 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 11 Nov 2020 13:06:03 +0100 Subject: [PATCH] handle upload failures better --- src/domain/session/room/timeline/tiles/FileTile.js | 2 +- src/matrix/room/sending/SendQueue.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/domain/session/room/timeline/tiles/FileTile.js b/src/domain/session/room/timeline/tiles/FileTile.js index 2c293c6c..eab55136 100644 --- a/src/domain/session/room/timeline/tiles/FileTile.js +++ b/src/domain/session/room/timeline/tiles/FileTile.js @@ -25,7 +25,7 @@ export class FileTile extends MessageTile { this._downloading = false; if (this._isUploading) { // should really do this with an ObservableValue and waitFor to prevent leaks when the promise never resolves - this._entry.attachment.uploaded().then(() => { + this._entry.attachment.uploaded().finally(() => { if (!this.isDisposed) { this.emitChange("label"); } diff --git a/src/matrix/room/sending/SendQueue.js b/src/matrix/room/sending/SendQueue.js index 8d367cb2..76ff2c66 100644 --- a/src/matrix/room/sending/SendQueue.js +++ b/src/matrix/room/sending/SendQueue.js @@ -53,7 +53,13 @@ export class SendQueue { } if (pendingEvent.attachment) { const {attachment} = pendingEvent; - await attachment.uploaded(); + try { + await attachment.uploaded(); + } catch (err) { + console.log("upload failed, skip sending message", pendingEvent); + this._amountSent += 1; + continue; + } attachment.applyToContent(pendingEvent.content); } if (pendingEvent.needsEncryption) {