diff --git a/src/services/migration.ts b/src/services/migration.ts index 4e1f82473..f8814b333 100644 --- a/src/services/migration.ts +++ b/src/services/migration.ts @@ -20,7 +20,7 @@ async function migrate() { if (currentDbVersion < 214) { log.error("Direct migration from your current version is not supported. Please upgrade to the latest v0.60.4 first and only then to this version."); - utils.crash(); + await utils.crash(); return; } @@ -84,7 +84,7 @@ async function migrate() { log.error("migration failed, crashing hard"); // this is not very user-friendly :-/ utils.crash(); - break; // crash() above does not seem to work right away + break; // crash() is sometimes async } } }); @@ -135,7 +135,7 @@ async function migrateIfNecessary() { if (currentDbVersion > appInfo.dbVersion && process.env.TRILIUM_IGNORE_DB_VERSION !== 'true') { log.error(`Current DB version ${currentDbVersion} is newer than the current DB version ${appInfo.dbVersion}, which means that it was created by a newer and incompatible version of Trilium. Upgrade to the latest version of Trilium to resolve this issue.`); - utils.crash(); + await utils.crash(); } if (!isDbUpToDate()) { diff --git a/src/services/utils.ts b/src/services/utils.ts index 1b75046d0..0747f744f 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -125,11 +125,10 @@ function escapeRegExp(str: string) { return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); } -function crash() { +async function crash() { if (isElectron()) { - require('electron').app.exit(1); - } - else { + (await import("electron")).app.exit(1); + } else { process.exit(1); } }