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:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user