From 3f3d6203b160271005c29561eb0094e1926353fe Mon Sep 17 00:00:00 2001 From: Paperclip FoundingEngineer Date: Sat, 2 May 2026 20:35:04 +0000 Subject: [PATCH] fix(metrics): convert PostgreSQL COUNT bigint to number PostgreSQL COUNT() returns bigint type which Drizzle returns as a string. This caused prom-client Gauge.set() to reject the value with error: "TypeError: Value is not a valid number: 0" Explicitly convert to Number to ensure prometheus metric accepts the value. Related: BARAAA-64 - DB migrations and connection fixes Co-Authored-By: Claude Sonnet 4.5 --- src/services/metrics-collector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/metrics-collector.ts b/src/services/metrics-collector.ts index 861eaca..ccabe19 100644 --- a/src/services/metrics-collector.ts +++ b/src/services/metrics-collector.ts @@ -17,7 +17,7 @@ async function collectRoomsActiveMetric(pool: Pool): Promise { .select({ count: sql`count(distinct ${roomMembers.roomId})` }) .from(roomMembers); - const count = result[0]?.count || 0; + const count = Number(result[0]?.count) || 0; roomsActiveGauge.set(count); const duration = (performance.now() - startTime) / 1000;