From d965d57be7b3b342ffabb2ea61fd100f028741ed Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 2 Jun 2021 18:44:03 +0200 Subject: [PATCH] don't leak timeline when an error is thrown while opening it or you are just stuck with "not dealing with race" errors until refresh --- src/matrix/room/BaseRoom.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/matrix/room/BaseRoom.js b/src/matrix/room/BaseRoom.js index f3d2a707..531f6a1a 100644 --- a/src/matrix/room/BaseRoom.js +++ b/src/matrix/room/BaseRoom.js @@ -404,10 +404,16 @@ export class BaseRoom extends EventEmitter { clock: this._platform.clock, logger: this._platform.logger, }); - if (this._roomEncryption) { - this._timeline.enableEncryption(this._decryptEntries.bind(this, DecryptionSource.Timeline)); + try { + if (this._roomEncryption) { + this._timeline.enableEncryption(this._decryptEntries.bind(this, DecryptionSource.Timeline)); + } + await this._timeline.load(this._user, this.membership, log); + } catch (err) { + // this also clears this._timeline in the closeCallback + this._timeline.dispose(); + throw err; } - await this._timeline.load(this._user, this.membership, log); return this._timeline; }); }