From 93b39d3c088086a4bebea6085c0ae2a118052e33 Mon Sep 17 00:00:00 2001 From: Ranko Orlic Date: Tue, 9 Apr 2024 17:31:53 +0200 Subject: [PATCH] fix: do not crash if label missing --- src/controller.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/controller.ts b/src/controller.ts index c392e69..e4e7280 100644 --- a/src/controller.ts +++ b/src/controller.ts @@ -319,16 +319,22 @@ export class Controller { jmeter.on('close', (code, signal) => { try { if (!!signal) { - console.info(`[WARN] Ignoring process exit code '${code}' for test ${id} because received signal ${signal}`); + console.warn(`[WARN] Ignoring process exit code '${code}' for test ${id} because received signal ${signal}`); } else { - const duration = endTimer && endTimer({ ...labels, category: run.category, name: run.name }); + let duration: number | undefined; + try { + duration = endTimer && endTimer({ ...labels, category: run.category, name: run.name }); + } catch (error) { + console.warn(`[WARN] Cannot calculate duration for test ${id} because: ${error}`); + duration = undefined; + } const updatedTest = { run: { ...run, status: TestRunStatus.done, code: code, duration: duration }, process: jmeter } as Test; const updatedRun = this._upsertTest(updatedTest).run; this._writeMetadata(updatedRun); this._moveToResults(updatedRun.id); } } catch (error) { - console.error('[ERROR] Failed to write metadata because: ', error); + console.error(`[ERROR] Failed to write metadata because: ${error}`); } });