mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 21:10:42 +00:00
fix: verify updated gateway version after package restart
This commit is contained in:
@@ -305,6 +305,38 @@ describe("inspectGatewayRestart", () => {
|
||||
expect(snapshot.versionMismatch).toBeUndefined();
|
||||
});
|
||||
|
||||
it("stops waiting once the restarted gateway reports the wrong version", async () => {
|
||||
probeGateway.mockResolvedValue({
|
||||
ok: true,
|
||||
close: null,
|
||||
server: { version: "2026.4.23", connId: "old" },
|
||||
});
|
||||
inspectPortUsage.mockResolvedValue({
|
||||
port: 18789,
|
||||
status: "busy",
|
||||
listeners: [{ pid: 8000, commandLine: "openclaw-gateway" }],
|
||||
hints: [],
|
||||
});
|
||||
|
||||
const { waitForGatewayHealthyRestart } = await import("./restart-health.js");
|
||||
const snapshot = await waitForGatewayHealthyRestart({
|
||||
service: makeGatewayService({ status: "running", pid: 8000 }),
|
||||
port: 18789,
|
||||
expectedVersion: "2026.4.24",
|
||||
});
|
||||
|
||||
expect(snapshot).toMatchObject({
|
||||
healthy: false,
|
||||
waitOutcome: "version-mismatch",
|
||||
elapsedMs: 0,
|
||||
versionMismatch: {
|
||||
expected: "2026.4.24",
|
||||
actual: "2026.4.23",
|
||||
},
|
||||
});
|
||||
expect(sleep).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("marks matching-version restarts unhealthy when activated plugins failed to load", async () => {
|
||||
probeGateway.mockResolvedValue({
|
||||
ok: true,
|
||||
|
||||
@@ -26,6 +26,7 @@ const WINDOWS_STOPPED_FREE_EARLY_EXIT_GRACE_MS = 90_000;
|
||||
export type GatewayRestartWaitOutcome =
|
||||
| "healthy"
|
||||
| "plugin-errors"
|
||||
| "version-mismatch"
|
||||
| "stale-pids"
|
||||
| "stopped-free"
|
||||
| "timeout";
|
||||
@@ -414,6 +415,9 @@ export async function waitForGatewayHealthyRestart(params: {
|
||||
if (snapshot.activatedPluginErrors?.length) {
|
||||
return withWaitContext(snapshot, "plugin-errors", attempt * delayMs);
|
||||
}
|
||||
if (snapshot.versionMismatch) {
|
||||
return withWaitContext(snapshot, "version-mismatch", attempt * delayMs);
|
||||
}
|
||||
if (snapshot.staleGatewayPids.length > 0 && snapshot.runtime.status !== "running") {
|
||||
return withWaitContext(snapshot, "stale-pids", attempt * delayMs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user