From a6cf7a4fdc3e6af911eff63dc17d5f2a0b668816 Mon Sep 17 00:00:00 2001 From: Nikhil Shahi Date: Sun, 25 Sep 2022 03:34:03 -0500 Subject: [PATCH] fix collector populate auth config --- backend/src/collector.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/src/collector.ts b/backend/src/collector.ts index 2edc147f..6143ff65 100644 --- a/backend/src/collector.ts +++ b/backend/src/collector.ts @@ -110,6 +110,7 @@ const populateAuthentication = async () => { } const queryRunner = AppDataSource.createQueryRunner() await queryRunner.connect() + await queryRunner.startTransaction() try { const metloConfig: object = yaml.load( fs.readFileSync("./metlo-config.yaml", "utf-8"), @@ -138,8 +139,10 @@ const populateAuthentication = async () => { .values(authConfigEntries) await deleteQb.execute() await addQb.execute() + await queryRunner.commitTransaction() } catch (err) { console.error(`Error in populating metlo config authentication: ${err}`) + await queryRunner.rollbackTransaction() } finally { await queryRunner?.release() }