Skip to content

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

fix(migrations): resolve NaN issue in gap reconciliation logic

diegosouzapwb75b52eefbb0
diff --git a/next.config.mjs b/next.config.mjs
index fa07570931..ec8a93f7de 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -177,6 +177,7 @@ const nextConfig = {
tls: false,
crypto: false,
process: false,
+ os: false,
};
}
return config;
diff --git a/src/lib/db/migrationRunner.ts b/src/lib/db/migrationRunner.ts
index e7aebd1423..338d7aa9ec 100644
--- a/src/lib/db/migrationRunner.ts
+++ b/src/lib/db/migrationRunner.ts
@@ -560,7 +560,10 @@ export function runMigrations(db: Database.Database, options?: { isNewDb?: boole
// Do not rely on any highest-version-applied heuristic. We must explicitly
// iterate through all missing files on disk and apply them if they are missing
// from the _omniroute_migrations table.
- const highestApplied = applied.size > 0 ? Math.max(...Array.from(applied).map(Number)) : 0;
+ const numericApplied = Array.from(applied)
+ .map((v) => Number.parseInt(v, 10))
+ .filter((n) => !Number.isNaN(n));
+ const highestApplied = numericApplied.length > 0 ? Math.max(...numericApplied) : 0;
const pending = files.filter((f) => {
const isMissing = !applied.has(f.version);
if (isMissing && Number(f.version) < highestApplied) {
diff --git a/tests/unit/next-config.test.ts b/tests/unit/next-config.test.ts
index a401c8770a..3442837f1a 100644
--- a/tests/unit/next-config.test.ts
+++ b/tests/unit/next-config.test.ts
@@ -111,5 +111,6 @@ test("next config webpack client branch disables Node builtins in browser bundle
tls: false,
crypto: false,
process: false,
+ os: false,
});
});