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

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