mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-15 09:31:21 +00:00
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
This commit is contained in:
parent
bd0b3875ba
commit
68d953aeeb
1 changed files with 9 additions and 3 deletions
|
|
@ -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 = [];
|
||||
}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue