@lobehub/chat 1.85.3 → 1.85.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/changelog/v1.json +9 -0
- package/package.json +1 -1
- package/src/database/client/db.ts +40 -5
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.85.4](https://github.com/lobehub/lobe-chat/compare/v1.85.3...v1.85.4)
|
6
|
+
|
7
|
+
<sup>Released on **2025-05-10**</sup>
|
8
|
+
|
9
|
+
#### 🐛 Bug Fixes
|
10
|
+
|
11
|
+
- **misc**: Fix nothing return when reset the client db.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### What's fixed
|
19
|
+
|
20
|
+
- **misc**: Fix nothing return when reset the client db, closes [#7738](https://github.com/lobehub/lobe-chat/issues/7738) ([90efb13](https://github.com/lobehub/lobe-chat/commit/90efb13))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
### [Version 1.85.3](https://github.com/lobehub/lobe-chat/compare/v1.85.2...v1.85.3)
|
6
31
|
|
7
32
|
<sup>Released on **2025-05-10**</sup>
|
package/changelog/v1.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.85.
|
3
|
+
"version": "1.85.4",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
5
5
|
"keywords": [
|
6
6
|
"framework",
|
@@ -313,16 +313,33 @@ export class DatabaseManager {
|
|
313
313
|
}
|
314
314
|
|
315
315
|
async resetDatabase(): Promise<void> {
|
316
|
-
//
|
316
|
+
// 1. 关闭现有的 PGlite 连接(如果存在)
|
317
|
+
if (this.dbInstance) {
|
318
|
+
try {
|
319
|
+
// @ts-ignore
|
320
|
+
await (this.dbInstance.session as any).client.close();
|
321
|
+
console.log('PGlite instance closed successfully.');
|
322
|
+
} catch (e) {
|
323
|
+
console.error('Error closing PGlite instance:', e);
|
324
|
+
// 即使关闭失败,也尝试继续删除,IndexedDB 的 onblocked 或 onerror 会处理后续问题
|
325
|
+
}
|
326
|
+
}
|
327
|
+
|
328
|
+
// 2. 重置数据库实例和初始化状态
|
329
|
+
this.dbInstance = null;
|
330
|
+
this.initPromise = null;
|
331
|
+
this.isLocalDBSchemaSynced = false; // 重置同步状态
|
332
|
+
|
333
|
+
// 3. 删除 IndexedDB 数据库
|
317
334
|
return new Promise<void>((resolve, reject) => {
|
318
335
|
// 检查 IndexedDB 是否可用
|
319
336
|
if (typeof indexedDB === 'undefined') {
|
320
337
|
console.warn('IndexedDB is not available, cannot delete database');
|
321
|
-
resolve();
|
338
|
+
resolve(); // 在此环境下无法删除,直接解决
|
322
339
|
return;
|
323
340
|
}
|
324
341
|
|
325
|
-
const dbName = `/pglite/${DB_NAME}`;
|
342
|
+
const dbName = `/pglite/${DB_NAME}`; // PGlite IdbFs 使用的路径
|
326
343
|
const request = indexedDB.deleteDatabase(dbName);
|
327
344
|
|
328
345
|
request.onsuccess = () => {
|
@@ -338,8 +355,26 @@ export class DatabaseManager {
|
|
338
355
|
|
339
356
|
// eslint-disable-next-line unicorn/prefer-add-event-listener
|
340
357
|
request.onerror = (event) => {
|
341
|
-
|
342
|
-
|
358
|
+
const error = (event.target as IDBOpenDBRequest)?.error;
|
359
|
+
console.error(`❌ Error resetting database '${dbName}':`, error);
|
360
|
+
reject(
|
361
|
+
new Error(
|
362
|
+
`Failed to reset database '${dbName}'. Error: ${error?.message || 'Unknown error'}`,
|
363
|
+
),
|
364
|
+
);
|
365
|
+
};
|
366
|
+
|
367
|
+
request.onblocked = (event) => {
|
368
|
+
// 当其他打开的连接阻止数据库删除时,会触发此事件
|
369
|
+
console.warn(
|
370
|
+
`Deletion of database '${dbName}' is blocked. This usually means other connections (e.g., in other tabs) are still open. Event:`,
|
371
|
+
event,
|
372
|
+
);
|
373
|
+
reject(
|
374
|
+
new Error(
|
375
|
+
`Failed to reset database '${dbName}' because it is blocked by other open connections. Please close other tabs or applications using this database and try again.`,
|
376
|
+
),
|
377
|
+
);
|
343
378
|
};
|
344
379
|
});
|
345
380
|
}
|