From 55eaebe8a19068df164180ecd3deaf80e425f518 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 19 Feb 2024 16:13:32 +0500 Subject: [PATCH] web: destroy sql database on app close --- apps/web/src/common/db.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/web/src/common/db.ts b/apps/web/src/common/db.ts index fac7590c6..c2b53917c 100644 --- a/apps/web/src/common/db.ts +++ b/apps/web/src/common/db.ts @@ -98,6 +98,10 @@ async function initializeDatabase(persistence: DatabasePersistence) { await db.init(); + window.addEventListener("beforeunload", () => { + db.sql().destroy(); + }); + logger.measure("Database initialization"); if (db.migrations?.required()) {