From debe2c527323dff044528f12ec2a220efad8d992 Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Sat, 10 Oct 2026 11:40:00 -0400 Subject: [PATCH 1/2] fix(monitoring): record non-Error health failures Signed-off-by: Rudy Celekli --- tests/monitor-health-rejections.test.mjs | 16 ++++++++++++++++ v3/@claude-flow/cli/src/production/monitoring.ts | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/monitor-health-rejections.test.mjs diff --git a/tests/monitor-health-rejections.test.mjs b/tests/monitor-health-rejections.test.mjs new file mode 100644 index 0000000000..f59c1f1b29 --- /dev/null +++ b/tests/monitor-health-rejections.test.mjs @@ -0,0 +1,16 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { MonitoringHooks } from '../v3/@claude-flow/cli/src/production/monitoring.ts'; +test('non-Error health failures are recorded without aborting later checks', async () => { + const m = new MonitoringHooks(); + for (const [name, value] of [['null', null], ['undefined', undefined], ['string', 'offline']]) m.registerHealthCheck(name, async () => { throw value; }); + m.registerHealthCheck('healthy', async () => ({ healthy: true })); + const result = await m.runHealthChecks(); + assert.equal(result.healthy, false); + for (const [name, value] of [['null', null], ['undefined', undefined], ['string', 'offline']]) { assert.equal(result.checks[name].status, 'unhealthy'); assert.equal(result.checks[name].message, String(value)); } + assert.equal(result.checks.healthy.status, 'healthy'); +}); +test('Error rejection retains the original message', async () => { + const m = new MonitoringHooks(); m.registerHealthCheck('error', async () => { throw new Error('unavailable'); }); + assert.equal((await m.runHealthChecks()).checks.error.message, 'unavailable'); +}); diff --git a/v3/@claude-flow/cli/src/production/monitoring.ts b/v3/@claude-flow/cli/src/production/monitoring.ts index 15298fad19..7b664bd13d 100644 --- a/v3/@claude-flow/cli/src/production/monitoring.ts +++ b/v3/@claude-flow/cli/src/production/monitoring.ts @@ -254,7 +254,7 @@ export class MonitoringHooks { } catch (error) { checks[name] = { status: 'unhealthy', - message: (error as Error).message, + message: error instanceof Error ? error.message : String(error), lastCheck: Date.now(), responseTimeMs: Date.now() - startTime, }; From 41e6610ea7c39bb0e75697bbf9681df5b9020054 Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Sat, 10 Oct 2026 15:34:55 -0400 Subject: [PATCH 2/2] test: run focused regressions with the repository Vitest runner Signed-off-by: Rudy Celekli --- tests/monitor-health-rejections.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/monitor-health-rejections.test.mjs b/tests/monitor-health-rejections.test.mjs index f59c1f1b29..5e0c078b01 100644 --- a/tests/monitor-health-rejections.test.mjs +++ b/tests/monitor-health-rejections.test.mjs @@ -1,4 +1,4 @@ -import test from 'node:test'; +import { test } from 'vitest'; import assert from 'node:assert/strict'; import { MonitoringHooks } from '../v3/@claude-flow/cli/src/production/monitoring.ts'; test('non-Error health failures are recorded without aborting later checks', async () => {