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

@@ -260,6 +260,8 @@ export async function resolveGlobalManager(params: {
}
const COMPLETION_CACHE_WRITE_TIMEOUT_MS = 30_000;
const COMPLETION_CACHE_MANUAL_REFRESH_HINT =
"Shell tab-completion may be stale; refresh manually with: openclaw completion --write-state";
export async function tryWriteCompletionCache(root: string, jsonMode: boolean): Promise<void> {
const binPath = path.join(root, "openclaw.mjs");
@@ -279,7 +281,16 @@ export async function tryWriteCompletionCache(root: string, jsonMode: boolean):
if (result.error) {
if (!jsonMode) {
defaultRuntime.log(theme.warn(`Completion cache update failed: ${String(result.error)}`));
const err = result.error as NodeJS.ErrnoException;
const reason =
err.code === "ETIMEDOUT"
? `timed out after ${COMPLETION_CACHE_WRITE_TIMEOUT_MS / 1000}s`
: String(result.error);
defaultRuntime.log(
theme.warn(
`Completion cache update failed: ${reason}. ${COMPLETION_CACHE_MANUAL_REFRESH_HINT}`,
),
);
}
return;
}
@@ -287,7 +298,11 @@ export async function tryWriteCompletionCache(root: string, jsonMode: boolean):
if (result.status !== 0 && !jsonMode) {
const stderr = (result.stderr ?? "").trim();
const detail = stderr ? ` (${stderr})` : "";
defaultRuntime.log(theme.warn(`Completion cache update failed${detail}.`));
defaultRuntime.log(
theme.warn(
`Completion cache update failed${detail}. ${COMPLETION_CACHE_MANUAL_REFRESH_HINT}`,
),
);
}
}