Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(db): prevent native module errors from renaming db and bump mass-migration safety threshold
diegosouzapw661a63cc4583
diff --git a/package-lock.json b/package-lock.jsonindex 0f60997a60..a8d13eb3a8 100644--- a/package-lock.json+++ b/package-lock.json@@ -51,7 +51,7 @@"zustand": "^5.0.10"},"bin": {- "omniroute": "bin/omniroute.ts",+ "omniroute": "bin/omniroute.mjs","omniroute-reset-password": "bin/reset-password.mjs"},"devDependencies": {@@ -84,7 +84,7 @@"wtfnode": "^0.10.1"},"engines": {- "node": ">=20.20.2 <21 || >=22.22.2 <23"+ "node": ">=20.20.2 <21 || >=22.22.2 <23 || >=24.0.0 <25"},"optionalDependencies": {"keytar": "^7.9.0"diff --git a/src/lib/db/core.ts b/src/lib/db/core.tsindex 715d5f6b3d..a97209e27b 100644--- a/src/lib/db/core.ts+++ b/src/lib/db/core.ts@@ -882,6 +882,17 @@ export function getDbInstance(): SqliteDatabase {} catch (e: unknown) {const message = e instanceof Error ? e.message : String(e);console.warn("[DB] Could not probe existing DB:", message);++ // If the error is a Node module/ABI failure, throw it immediately to avoid renaming the database+ if (+ message.includes("Module did not self-register") ||+ message.includes("could not be found") ||+ message.includes("ERR_DLOPEN_FAILED") ||+ (e as any)?.code === "ERR_DLOPEN_FAILED"+ ) {+ throw e;+ }+// SAFETY: Never delete the database — rename to backup so data can be recovered.// The old code would silently destroy all user data on any probe failure.const failedPath = sqliteFile + `.probe-failed-${Date.now()}`;diff --git a/src/lib/db/migrationRunner.ts b/src/lib/db/migrationRunner.tsindex 8e5517dcad..65198f49ba 100644--- a/src/lib/db/migrationRunner.ts+++ b/src/lib/db/migrationRunner.ts@@ -48,7 +48,7 @@ const MIGRATIONS_DIR = resolveMigrationsDir();** Set to 0 to disable this safety check.*/-const MAX_PENDING_MIGRATIONS_ON_EXISTING_DB = 5;+const MAX_PENDING_MIGRATIONS_ON_EXISTING_DB = 50;const RENAMED_MIGRATION_COMPATIBILITY = [{