Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 9939c9d

Browse files
authored
Clean up rageshake store at startup (#12002)
1 parent 845838b commit 9939c9d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/rageshake/rageshake.ts

+12
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,14 @@ export function tryInitStorage(): Promise<void> {
529529
if (indexedDB) {
530530
global.mx_rage_store = new IndexedDBLogStore(indexedDB, global.mx_rage_logger);
531531
global.mx_rage_initStoragePromise = global.mx_rage_store.connect();
532+
533+
// Fire off a task in the background which will clean up old logs in the store
534+
global.mx_rage_initStoragePromise.then(() => {
535+
global.mx_rage_store.consume().catch((e) => {
536+
logger.error("Error cleaning up rageshake store", e);
537+
});
538+
});
539+
532540
return global.mx_rage_initStoragePromise;
533541
}
534542
global.mx_rage_initStoragePromise = Promise.resolve();
@@ -544,6 +552,10 @@ export function flush(): void {
544552

545553
/**
546554
* Clean up old logs.
555+
*
556+
* @deprecated There is no need to call this explicitly: it will be done as a side-effect of {@link tryInitStorage},
557+
* or {@link init} with `setUpPersistence: true`.
558+
*
547559
* @return {Promise} Resolves if cleaned logs.
548560
*/
549561
export async function cleanup(): Promise<void> {

0 commit comments

Comments
 (0)