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

Fix bug which prevented correct clean up of rageshake store #12002

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/rageshake/rageshake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,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();
Expand All @@ -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<void> {
Expand Down
Loading