Clean up rageshake store at startup (#12002)

pull/28788/head^2
Richard van der Hoff 2023-12-07 17:13:49 +00:00 committed by GitHub
parent 845838b67f
commit 9939c9d01d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -529,6 +529,14 @@ export function tryInitStorage(): Promise<void> {
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<void> {