fix: stabilize Parallels update restart checks

This commit is contained in:
Peter Steinberger
2026-04-30 04:56:06 +01:00
parent d363565375
commit e648f38efc
4 changed files with 270 additions and 52 deletions

View File

@@ -351,6 +351,35 @@ describe("inspectGatewayRestart", () => {
expect(snapshot.versionMismatch).toBeUndefined();
});
it("accepts matching-version restart liveness when the probe lacks operator scope", async () => {
probeGateway.mockResolvedValue({
ok: false,
close: null,
connectLatencyMs: 12,
error: "missing scope: operator.read",
auth: { capability: "connected_no_operator_scope" },
server: { version: "2026.4.24", connId: "new" },
});
const snapshot = await inspectGatewayRestartWithSnapshot({
runtime: { status: "running", pid: 8000 },
expectedVersion: "2026.4.24",
portUsage: {
port: 18789,
status: "busy",
listeners: [{ pid: 8000, commandLine: "openclaw-gateway" }],
hints: [],
},
});
expect(snapshot).toMatchObject({
healthy: true,
gatewayVersion: "2026.4.24",
expectedVersion: "2026.4.24",
});
expect(snapshot.versionMismatch).toBeUndefined();
});
it("stops waiting once the restarted gateway reports the wrong version", async () => {
probeGateway.mockResolvedValue({
ok: true,

View File

@@ -237,8 +237,14 @@ async function confirmGatewayReachable(params: {
timeoutMs: 3_000,
includeDetails: params.includeHealthDetails === true,
});
const reachedGateway =
probe.ok ||
looksLikeAuthClose(probe.close?.code, probe.close?.reason) ||
(probe.connectLatencyMs != null &&
probe.server?.version != null &&
probe.auth.capability === "connected_no_operator_scope");
return {
reachable: probe.ok || looksLikeAuthClose(probe.close?.code, probe.close?.reason),
reachable: reachedGateway,
gatewayVersion: probe.server?.version ?? null,
activatedPluginErrors: readActivatedPluginErrors(probe.health),
channelProbeErrors: readChannelProbeErrors(probe.health),