diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js --- a/web/shared-worker/worker/worker-crypto.js +++ b/web/shared-worker/worker/worker-crypto.js @@ -250,11 +250,6 @@ throw new Error('Database not initialized'); } - // This `olm.Account` is created once and is cached for the entire - // program lifetime. Freeing is done as part of `clearCryptoStore`. - const account = new olm.Account(); - let picklingKey; - let accountDBString; try { accountDBString = @@ -288,6 +283,11 @@ }; } + // This `olm.Account` is created once and is cached for the entire + // program lifetime. Freeing is done as part of `clearCryptoStore`. + const account = new olm.Account(); + let picklingKey; + if (accountDBString.isNull) { picklingKey = uuid.v4(); account.create(); @@ -526,6 +526,8 @@ }; await persistCryptoStore(notifsCryptoAccount); + + notifsCryptoAccount.notificationAccount.free(); }, async getUserPublicKey(): Promise { if (!cryptoStore) {