From 43c81358b2af6b4f5c43e63259f0d9f2c35da213 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 7 Aug 2022 01:13:06 +0100 Subject: [PATCH] don't load the sync accumulator if there's already a sync persist in flight this should hopefully reduce chances of https://github.com/vector-im/element-web/issues/21541 a bit more as we were incorrectly loading the sync accumulator even if a sync persist was already in flight, thus wasting RAM and increasing the chance of the renderer process OOMing --- src/store/indexeddb-local-backend.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/indexeddb-local-backend.ts b/src/store/indexeddb-local-backend.ts index bd646c37202..7e4bd767364 100644 --- a/src/store/indexeddb-local-backend.ts +++ b/src/store/indexeddb-local-backend.ts @@ -409,8 +409,6 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend { } public async syncToDatabase(userTuples: UserTuple[]): Promise { - const syncData = this.syncAccumulator.getJSON(true); - if (this.isPersisting) { logger.warn("Skipping syncToDatabase() as persist already in flight"); this.pendingUserPresenceData.push(...userTuples); @@ -421,6 +419,8 @@ export class LocalIndexedDBStoreBackend implements IIndexedDBBackend { } try { + const syncData = this.syncAccumulator.getJSON(true); + await Promise.all([ this.persistUserPresenceEvents(userTuples), this.persistAccountData(syncData.accountData),