From 9939c9d01d3ea7921414ca010a636f2bd39dd90c Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 7 Dec 2023 17:13:49 +0000 Subject: [PATCH] Clean up rageshake store at startup (#12002) --- src/rageshake/rageshake.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rageshake/rageshake.ts b/src/rageshake/rageshake.ts index 96959933b8..87e9752e80 100644 --- a/src/rageshake/rageshake.ts +++ b/src/rageshake/rageshake.ts @@ -529,6 +529,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(); @@ -544,6 +552,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 {