chore(standalone): get bootstrap to report not initialized state

This commit is contained in:
Elian Doran
2026-03-23 18:54:44 +02:00
parent 794dab2894
commit 79db638bf4
3 changed files with 20 additions and 5 deletions

View File

@@ -4,7 +4,7 @@
*/
import { BootstrapDefinition } from '@triliumnext/commons';
import { entity_changes, getContext, getSharedBootstrapItems, getSql, routes } from '@triliumnext/core';
import { entity_changes, getContext, getSharedBootstrapItems, getSql, routes, sql_init } from '@triliumnext/core';
import packageJson from '../../package.json' with { type: 'json' };
import { type BrowserRequest, BrowserRouter } from './browser_router';
@@ -220,10 +220,17 @@ export function registerRoutes(router: BrowserRouter): void {
apiRoute("get", "/api/system-checks", () => ({ isCpuArchMismatch: false }));
}
function bootstrapRoute() {
function bootstrapRoute(): BootstrapDefinition {
const assetPath = ".";
if (!sql_init.isDbInitialized()) {
return {
dbInitialized: false
};
}
return {
dbInitialized: true,
...getSharedBootstrapItems(assetPath),
appPath: assetPath,
device: false, // Let the client detect device type.
@@ -248,7 +255,7 @@ function bootstrapRoute() {
instanceName: null,
appCssNoteIds: [],
TRILIUM_SAFE_MODE: false
} satisfies BootstrapDefinition;
};
}
/**

View File

@@ -169,7 +169,12 @@ async function initialize(): Promise<void> {
console.log("[Worker] Router configured");
console.log("[Worker] Initializing becca...");
await coreModule.becca_loader.beccaLoaded;
if (coreModule.sql_init.isDbInitialized()) {
console.log("[Worker] Database already initialized, loading becca...");
await coreModule.becca_loader.beccaLoaded;
} else {
console.log("[Worker] Database not initialized, skipping becca load (will be loaded during DB initialization)");
}
console.log("[Worker] Initialization complete");
} catch (error) {

View File

@@ -312,7 +312,8 @@ export interface DefinitionObject {
inverseRelation?: string;
}
export interface BootstrapDefinition {
export type BootstrapDefinition = {
dbInitialized: true;
device: "mobile" | "desktop" | "print" | false;
csrfToken: string;
themeCssUrl: string | false;
@@ -340,6 +341,8 @@ export interface BootstrapDefinition {
iconPackCss: string;
iconRegistry: IconRegistry;
TRILIUM_SAFE_MODE: boolean;
} | {
dbInitialized: false;
}
/**