From a003b1fdc4d45264a6689bb8bc477b82fb902aa5 Mon Sep 17 00:00:00 2001 From: Jan Leon Date: Tue, 30 Jun 2026 02:56:20 +0200 Subject: [PATCH] chore: remove unused headroom log tail export (#5464) --- src/lib/headroom/process.ts | 20 ++------------------ tests/unit/headroom-proxy-lifecycle.test.ts | 7 +++++++ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/lib/headroom/process.ts b/src/lib/headroom/process.ts index b788bf6600..7e5ddeaeaf 100644 --- a/src/lib/headroom/process.ts +++ b/src/lib/headroom/process.ts @@ -89,9 +89,7 @@ function safePort(port: unknown): number { return Number.isFinite(n) && n > 0 && n < 65536 ? n : DEFAULT_PORT; } -export async function startHeadroomProxy( - opts: { port?: number } = {} -): Promise { +export async function startHeadroomProxy(opts: { port?: number } = {}): Promise { const binary = findHeadroomBinary(); if (!binary) { throw new HeadroomError("Headroom CLI not installed", "NOT_INSTALLED"); @@ -125,10 +123,7 @@ export async function startHeadroomProxy( if (isPidAlive(child.pid!)) resolve(); else reject( - new HeadroomError( - "headroom proxy exited during startup — see proxy.log", - "EARLY_EXIT" - ) + new HeadroomError("headroom proxy exited during startup — see proxy.log", "EARLY_EXIT") ); }, STARTUP_TIMEOUT_MS); @@ -180,14 +175,3 @@ export function stopHeadroomProxy(): StopResult { throw new HeadroomError(`Failed to stop headroom proxy: ${msg}`, "STOP_FAILED"); } } - -export function getHeadroomLogTail(maxLines = 200): string { - try { - if (!fs.existsSync(LOG_FILE)) return ""; - const content = fs.readFileSync(LOG_FILE, "utf8"); - const lines = content.split(/\r?\n/).filter(Boolean); - return lines.slice(-maxLines).join("\n"); - } catch { - return ""; - } -} diff --git a/tests/unit/headroom-proxy-lifecycle.test.ts b/tests/unit/headroom-proxy-lifecycle.test.ts index 487ea71982..f16af0b18b 100644 --- a/tests/unit/headroom-proxy-lifecycle.test.ts +++ b/tests/unit/headroom-proxy-lifecycle.test.ts @@ -6,6 +6,7 @@ import { parsePortFromHeadroomUrl, buildHeadroomStatus, } from "../../src/lib/headroom/detect"; +import { getManagedPid, isPidAlive } from "../../src/lib/headroom/process"; import { isLocalOnlyPath } from "../../src/server/authz/routeGuard"; // ────────────────────────────────────────────────────────────────────────────── @@ -88,3 +89,9 @@ test("buildHeadroomStatus: nothing installed and proxy unreachable → all false assert.equal(status.localUrl, true); assert.equal(status.canStart, false); }); + +test("process status helpers are safe for absent managed processes", () => { + assert.equal(isPidAlive(null), false); + assert.equal(isPidAlive(undefined), false); + assert.equal(getManagedPid(), null); +});