From a3ad073d96833dde2a93e3818e7fb15d725c382a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ullrich=20Sch=C3=A4fer?= Date: Fri, 3 Apr 2026 09:15:15 +0100 Subject: [PATCH] Guard collectDefaultMetrics against duplicate registration Importing metrics.server.ts from yjs-server.ts caused collectDefaultMetrics() to re-register during HMR, crashing the planner dev server. Check if metrics already exist first. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/planner/app/lib/metrics.server.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/planner/app/lib/metrics.server.ts b/apps/planner/app/lib/metrics.server.ts index 85590c6..059e5ab 100644 --- a/apps/planner/app/lib/metrics.server.ts +++ b/apps/planner/app/lib/metrics.server.ts @@ -1,7 +1,10 @@ import client from "prom-client"; // Collect default Node.js metrics (event loop, heap, GC) -client.collectDefaultMetrics(); +// Guard against duplicate registration during HMR +if (!client.register.getSingleMetric("process_cpu_user_seconds_total")) { + client.collectDefaultMetrics(); +} export const httpRequestDuration = new client.Histogram({ name: "http_request_duration_seconds",