fix: close SQLite DB on shutdown to prevent lock conflicts on restart (#508)
* feat: add session export with full and compressed modes Add export functionality that allows users to download session data as JSON or plain text, with optional LLM-based context compression for long conversations. Includes UI controls in chat panel, session list, and history view, plus i18n strings for all 8 locales. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: close SQLite DB on shutdown to prevent lock conflicts on restart The shutdown handler did not close the SQLite connection, leaving the database locked when nodemon restarted the process. This caused the new process to fail DB init, trigger the recovery path (delete + recreate), and re-sync all sessions from Hermes on every dev restart. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -111,3 +111,15 @@ export function jsonDelete(table: string, key: string): void {
|
||||
export function getStoragePath(): string {
|
||||
return SQLITE_AVAILABLE ? DB_PATH : JSON_PATH
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the SQLite database connection.
|
||||
*/
|
||||
export function closeDb(): void {
|
||||
if (_db) {
|
||||
try {
|
||||
_db.close()
|
||||
} catch { /* best-effort */ }
|
||||
_db = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { logger } from './logger'
|
||||
import { closeDb } from '../db'
|
||||
|
||||
export function bindShutdown(server: any, groupChatServer?: any, chatRunServer?: any): void {
|
||||
let isShuttingDown = false
|
||||
@@ -35,6 +36,7 @@ export function bindShutdown(server: any, groupChatServer?: any, chatRunServer?:
|
||||
logger.error(err, 'Shutdown error')
|
||||
}
|
||||
|
||||
closeDb()
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user