diff --git a/src/matrix/SessionContainer.js b/src/matrix/SessionContainer.js index 9794e93a..6b194c9b 100644 --- a/src/matrix/SessionContainer.js +++ b/src/matrix/SessionContainer.js @@ -189,6 +189,8 @@ export class SessionContainer { log.set("status", this._status.get()); } catch (err) { log.catch(err); + // free olm Account that might be contained + dehydratedDevice?.dispose(); this._error = err; this._status.set(LoadStatus.Error); } diff --git a/src/matrix/e2ee/Dehydration.js b/src/matrix/e2ee/Dehydration.js index 4fa75d81..22d6082b 100644 --- a/src/matrix/e2ee/Dehydration.js +++ b/src/matrix/e2ee/Dehydration.js @@ -90,11 +90,16 @@ class DehydratedDevice { // make it clear that ownership is transfered upon calling this adoptUnpickledOlmAccount() { const account = this._account; - this._account = null; + this._account = undefined; return account; } get deviceId() { return this._dehydratedDevice.device_id; } + + dispose() { + this._account?.free(); + this._account = undefined; + } }