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
This commit is contained in:
Bruno Windels 2021-06-02 18:44:03 +02:00
parent 0c4c018ceb
commit d965d57be7
1 changed files with 9 additions and 3 deletions

View File

@ -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;
});
}