From ca4a06339a3b6bdb5f025b185429815308d9a661 Mon Sep 17 00:00:00 2001 From: LiangshouX Date: Tue, 3 Nov 2026 05:25:21 +0800 Subject: [PATCH] fix(dsh): skip auto-start for an endpoint that cannot launch With autoStart enabled and a path-prefixed endpoint configured, DSH startup asked for a start that buildStartCommand must refuse, logging a warning on every start. autoStart now checks the same launchability rule first and returns without probing or starting, so a remote or prefixed endpoint is left to connection probing. - Regression: auto-start does not probe a prefixed endpoint and spawns nothing, while a root-path endpoint still auto-starts. --- .../dsh/src/environment/host/manager.ts | 11 ++++++ integrations/dsh/tests/env-manager.test.mjs | 35 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/integrations/dsh/src/environment/host/manager.ts b/integrations/dsh/src/environment/host/manager.ts index ca8ff5e0..fe6fa821 100644 --- a/integrations/dsh/src/environment/host/manager.ts +++ b/integrations/dsh/src/environment/host/manager.ts @@ -316,6 +316,17 @@ export class ReMeEnvManager { workspaceDir: string; authToken?: string; }): Promise { + // Only a root-path loopback endpoint can become a local service. A + // configured gateway prefix (or a remote URL) is probed elsewhere, and a + // start could at best fail after stopping a same-origin service: skip it + // instead of reporting a failure on every DSH start. + let launchable = false; + try { + launchable = this.launchable(this.endpoint(options.endpoint)); + } catch { + launchable = false; + } + if (!launchable) return; const status = await this.serviceStatus( options.endpoint, options.authToken ?? "", diff --git a/integrations/dsh/tests/env-manager.test.mjs b/integrations/dsh/tests/env-manager.test.mjs index f91c9cc3..507fb580 100644 --- a/integrations/dsh/tests/env-manager.test.mjs +++ b/integrations/dsh/tests/env-manager.test.mjs @@ -80,6 +80,41 @@ test("serializes concurrent starts into one service launch", async (t) => { assert.equal(second.alreadyRunning, true); }); +test("auto-start only attempts a launch for a local root-path endpoint", async (t) => { + const { manager, calls, directory } = managerIn(t); + const workspace = join(directory, "workspace"); + const statuses = []; + manager.serviceStatus = async (endpoint) => { + statuses.push(endpoint); + return { + phase: "stopped", + managed: false, + endpoint, + logPath: join(directory, "service.log"), + }; + }; + + // A gateway prefix cannot be launched, so auto-start does not even probe it + // for a start: it could only fail after stopping a same-origin service, and + // would report a failure on every DSH start. + await manager.autoStart({ + endpoint: "http://127.0.0.1:2334/reme", + pythonPath: "D:\\env\\python.exe", + workspaceDir: workspace, + }); + assert.deepEqual(statuses, []); + assert.equal(calls.spawn.length, 0); + + // A root-path endpoint is auto-started as before. + await manager.autoStart({ + endpoint: "http://127.0.0.1:2334", + pythonPath: "D:\\env\\python.exe", + workspaceDir: workspace, + }); + assert.ok(statuses.length > 0); + assert.equal(calls.spawn.length, 1); +}); + test("a failed spawn can be retried immediately", async (t) => { const { manager, calls, directory, io } = managerIn(t); io.spawnService = async (options) => {