Skip to content

Build your personal knowledge base with Trilium Notes

fix(standalone): crashes in prod due to cyclic dep

Elian Doran001f144dc79f
diff --git a/packages/trilium-core/src/index.ts b/packages/trilium-core/src/index.ts
index 30755675a1..0b1f484bb0 100644
--- a/packages/trilium-core/src/index.ts
+++ b/packages/trilium-core/src/index.ts
@@ -159,7 +159,7 @@ export async function initializeCore({ dbConfig, executionContext, crypto, zip,
initZipProvider(zip);
initZipExportProviderFactory(zipExportProviderFactory);
initContext(executionContext);
- initSql(new SqlService(dbConfig, getLog()));
+ await initSql(new SqlService(dbConfig, getLog()));
initSchema(schema);
initImageProvider(image);
if (getDemoArchive) {
diff --git a/packages/trilium-core/src/services/sql/index.ts b/packages/trilium-core/src/services/sql/index.ts
index 09d06265f5..9003eaf7e3 100644
--- a/packages/trilium-core/src/services/sql/index.ts
+++ b/packages/trilium-core/src/services/sql/index.ts
@@ -1,11 +1,11 @@
-import sql_init from "../sql_init";
import type { SqlService } from "./sql";
let sql: SqlService | null = null;
-export function initSql(instance: SqlService) {
+export async function initSql(instance: SqlService) {
if (sql) throw new Error("SQL already initialized");
sql = instance;
+ const sql_init = (await import("../sql_init.js")).default;
sql_init.initializeDb();
}