fix(cli): clarify completion cache timeout message after openclaw update

When the post-update completion cache refresh times out (slow disk,
large bundled plugin tree, Docker overlayfs), the user previously saw
the opaque 'Completion cache update failed: Error: spawnSync
/usr/bin/node ETIMEDOUT'. Detect ETIMEDOUT specifically, surface
'timed out after 30s', and append a manual refresh hint pointing at
'openclaw completion --write-state' so users know it's non-fatal and
how to recover.

Fixes #72842
This commit is contained in:
iot2edge
2026-04-27 16:29:52 +02:00
committed by Peter Steinberger
parent cdf88bcad4
commit 98928388db
2 changed files with 42 additions and 2 deletions

View File

@@ -549,6 +549,31 @@ describe("update-cli", () => {
);
});
it("logs friendly hint with manual refresh command when completion cache write times out", async () => {
const root = createCaseDir("openclaw-completion-timeout-msg");
pathExists.mockResolvedValue(true);
const timeoutErr = Object.assign(new Error("spawnSync /usr/bin/node ETIMEDOUT"), {
code: "ETIMEDOUT",
});
vi.mocked(spawnSync).mockReturnValueOnce({
pid: 0,
output: [],
stdout: "",
stderr: "",
status: null,
signal: null,
error: timeoutErr,
});
vi.mocked(runtimeCapture.log).mockClear();
await updateCliShared.tryWriteCompletionCache(root, false);
const logs = vi.mocked(runtimeCapture.log).mock.calls.map((call) => String(call[0]));
expect(logs.some((line) => line.includes("timed out after 30s"))).toBe(true);
expect(logs.some((line) => line.includes("openclaw completion --write-state"))).toBe(true);
expect(logs.some((line) => line.includes("Error: spawnSync"))).toBe(false);
});
it("respawns into the updated package root before running post-update tasks", async () => {
const { entrypoints } = setupUpdatedRootRefresh();