fix(storage): close database after bootstrap failure

The bootstrap wrapper releases the SQLite handle when daemon construction fails before returning the normal shutdown owner.
This commit is contained in:
Mohamed Boudra
2026-08-13 22:24:14 +02:00
parent 5d195e7e15
commit ae3c0119f9
+14
View File
@@ -555,6 +555,20 @@ export async function createPaseoDaemon(
configureGitProcessPolicy(config.git ?? resolveGitProcessPolicy({ env: process.env }));
const logger = rootLogger.child({ module: "bootstrap" });
const database = openDatabase(config.paseoHome);
try {
return await createPaseoDaemonWithDatabase(config, logger, dependencies, database);
} catch (error) {
database.close();
throw error;
}
}
async function createPaseoDaemonWithDatabase(
config: PaseoDaemonConfig,
logger: Logger,
dependencies: PaseoDaemonDependencies,
database: ReturnType<typeof openDatabase>,
): Promise<PaseoDaemon> {
const bootstrapStart = performance.now();
const elapsed = () => `${(performance.now() - bootstrapStart).toFixed(0)}ms`;
const daemonVersion = config.daemonVersion ?? resolveDaemonVersion(import.meta.url);