mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-03 05:45:04 +03:00
fix(db): prevent native module errors from renaming db and bump mass-migration safety threshold
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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"
|
||||
|
||||
@@ -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()}`;
|
||||
|
||||
@@ -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 = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user