From 9ec6c9add3cb308a8d8549d85b7c74626feebab9 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Wed, 12 Aug 2026 21:30:35 +0800 Subject: [PATCH] fix: guard auto-start server to only run when executed directly, not when imported by tests --- packages/daemon/src/server.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/daemon/src/server.ts b/packages/daemon/src/server.ts index 8a97d2a..11ae70c 100644 --- a/packages/daemon/src/server.ts +++ b/packages/daemon/src/server.ts @@ -32,6 +32,9 @@ export function startServer(port: number, browserManager?: BrowserManager): Prom }); } -// Direct start when running as script -const port = parseInt(process.env.VISIONL_PORT || '9527', 10); -startServer(port); +// Direct start when running as script (not when imported in tests) +// When imported by other modules, the caller is responsible for calling startServer() +if (process.argv[1] && (process.argv[1].endsWith('server.js') || process.argv[1].endsWith('server.ts'))) { + const port = parseInt(process.env.VISIONL_PORT || '9527', 10); + startServer(port); +}