diff --git a/packages/server/src/db/hermes/schemas.ts b/packages/server/src/db/hermes/schemas.ts index af8b049..7995dab 100644 --- a/packages/server/src/db/hermes/schemas.ts +++ b/packages/server/src/db/hermes/schemas.ts @@ -543,8 +543,8 @@ export function initAllHermesTables(retryCount = 0): void { } // 3. 删除 WAL 和 SHM 文件 - try { unlinkSync(dbPath + '-wal') } catch {} - try { unlinkSync(dbPath + '-shm') } catch {} + try { unlinkSync(dbPath + '-wal') } catch { } + try { unlinkSync(dbPath + '-shm') } catch { } // 4. 重新初始化(增加重试计数) console.log('[Schema] Reinitializing database...') diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index b58d7c7..452c5e6 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -48,10 +48,12 @@ export async function bootstrap() { await initGatewayManager() console.log('[bootstrap] gateway manager initialized') - + await new Promise(resolve => setTimeout(resolve, 1000)) // Initialize all web-ui SQLite tables const { initAllStores } = await import('./db/hermes/init') + // Wait 1 second before initializing stores to ensure all resources are ready initAllStores() + await new Promise(resolve => setTimeout(resolve, 1000)) console.log('[bootstrap] all stores initialized') // Sync Hermes sessions from all profiles (only if local DB is empty)