fix(update): verify daemon restart port

This commit is contained in:
Vincent Koc
2026-05-01 04:54:19 -07:00
parent f6a1d70080
commit debb8ac76c
3 changed files with 42 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ import {
} from "../../daemon/gateway-entrypoint.js";
import {
shouldPrepareUpdatedInstallRestart,
resolveUpdatedGatewayRestartPort,
shouldUseLegacyProcessRestartAfterUpdate,
} from "./update-command.js";
@@ -83,6 +84,28 @@ describe("shouldPrepareUpdatedInstallRestart", () => {
});
});
describe("resolveUpdatedGatewayRestartPort", () => {
it("uses the managed service port ahead of the caller environment", () => {
expect(
resolveUpdatedGatewayRestartPort({
config: { gateway: { port: 19000 } } as never,
processEnv: { OPENCLAW_GATEWAY_PORT: "19001" },
serviceEnv: { OPENCLAW_GATEWAY_PORT: "19002" },
}),
).toBe(19002);
});
it("falls back to the post-update config when no service port is available", () => {
expect(
resolveUpdatedGatewayRestartPort({
config: { gateway: { port: 19000 } } as never,
processEnv: {},
serviceEnv: {},
}),
).toBe(19000);
});
});
describe("shouldUseLegacyProcessRestartAfterUpdate", () => {
it("never restarts package updates through the pre-update process", () => {
expect(shouldUseLegacyProcessRestartAfterUpdate({ updateMode: "npm" })).toBe(false);