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.
This commit is contained in:
LiangshouX 2026-11-03 05:25:21 +08:00
parent 8284088210
commit ca4a06339a
2 changed files with 46 additions and 0 deletions

View file

@ -316,6 +316,17 @@ export class ReMeEnvManager {
workspaceDir: string;
authToken?: string;
}): Promise<void> {
// 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 ?? "",

View file

@ -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) => {