cli: add error handling for config close and startup failure cleanup

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-04-02 00:38:35 +02:00
parent 13c5f97337
commit c0908fe5b5
2 changed files with 13 additions and 7 deletions
@@ -232,6 +232,9 @@ async function readDatabaseClient(
});
const config = await ConfigSources.toConfig(source);
config.close();
return config.getOptionalString('backend.database.client');
try {
return config.getOptionalString('backend.database.client');
} finally {
config.close();
}
}
@@ -92,11 +92,14 @@ export async function startEmbeddedDb() {
onLog() {},
});
// Create the cluster config files
await pg.initialise();
// Start the server
await pg.start();
try {
await pg.initialise();
await pg.start();
} catch (error) {
await pg.stop().catch(() => {});
await fs.remove(tmpDir).catch(() => {});
throw error;
}
return {
connection: {