From 68d953aeeb533f2d02cb631ee73f4c3ae4f0bf6d Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 4 Sep 2026 20:44:43 +0200 Subject: [PATCH] fix: app hangs on the loading spinner while cleaning up legacy local chat storage Users who still had the old browser-side chat database could land on the loading spinner forever, with a silent console and no way out short of clearing site data. The sidebar rendered, the chat area never did. The startup migration check opens the legacy 'Chats' IndexedDB and deletes it when it holds no chats. It never closed its own connection first, and indexedDB.deleteDatabase() stays blocked for as long as any connection is open, so the delete never completed and the awaited startup chain never finished. The same await sat behind the migration dialog's "Download & Delete" button, leaving that dialog up after the export had already been saved. The connection is now closed before the delete, and the migration check no longer blocks startup: it is best-effort, it already swallows its own errors, and nothing between it and the first render reads its results, so a browser whose IndexedDB never answers can no longer keep the app from loading. Measured against the real idb build with the legacy database seeded: the delete goes from never settling to completing in ~165 ms, in both the startup path and the dialog button. Fixes #29538 --- src/routes/(app)/+layout.svelte | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 0c96091268..4be4ec63d9 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -69,6 +69,12 @@ } }; + // deleteDB() stays blocked as long as a connection is open + const deleteLocalDBChats = async () => { + DB.close(); + await deleteDB('Chats'); + }; + const checkLocalDBChats = async () => { try { // Check if IndexedDB exists @@ -82,7 +88,7 @@ localDBChats = chats.map((item, idx) => chats[chats.length - 1 - idx]); if (localDBChats.length === 0) { - await deleteDB('Chats'); + await deleteLocalDBChats(); } } catch (error) { // IndexedDB Not Found @@ -245,9 +251,9 @@ } clearChatInputStorage(); + checkLocalDBChats(); try { await Promise.all([ - checkLocalDBChats(), setBanners().catch((e) => console.error('Failed to load banners:', e)), setTools().catch((e) => console.error('Failed to load tools:', e)), setUserSettings(async () => { @@ -509,7 +515,7 @@ const tx = DB.transaction('chats', 'readwrite'); await Promise.all([tx.store.clear(), tx.done]); - await deleteDB('Chats'); + await deleteLocalDBChats(); localDBChats = []; }}