diff --git a/src/rageshake/rageshake.ts b/src/rageshake/rageshake.ts index 885ece6b935..bd4774c58a1 100644 --- a/src/rageshake/rageshake.ts +++ b/src/rageshake/rageshake.ts @@ -474,6 +474,14 @@ export function tryInitStorage(): Promise { if (indexedDB) { global.mx_rage_store = new IndexedDBLogStore(indexedDB, global.mx_rage_logger); global.mx_rage_initStoragePromise = global.mx_rage_store.connect(); + + // Fire off a task in the background which will clean up old logs in the store + global.mx_rage_initStoragePromise.then(() => { + global.mx_rage_store.consume().catch((e) => { + logger.error("Error cleaning up rageshake store", e); + }); + }); + return global.mx_rage_initStoragePromise; } global.mx_rage_initStoragePromise = Promise.resolve(); @@ -489,6 +497,10 @@ export function flush(): void { /** * Clean up old logs. + * + * @deprecated There is no need to call this explicitly: it will be done as a side-effect of {@link tryInitStorage}, + * or {@link init} with `setUpPersistence: true`. + * * @return {Promise} Resolves if cleaned logs. */ export async function cleanup(): Promise {