fix(cli): clarify completion cache timeout message after openclaw update · openclaw/openclaw@9892838
iot2edge
·
2026-04-28
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -549,6 +549,31 @@ describe("update-cli", () => {
|
549 | 549 | ); |
550 | 550 | }); |
551 | 551 | |
| 552 | +it("logs friendly hint with manual refresh command when completion cache write times out", async () => { |
| 553 | +const root = createCaseDir("openclaw-completion-timeout-msg"); |
| 554 | +pathExists.mockResolvedValue(true); |
| 555 | +const timeoutErr = Object.assign(new Error("spawnSync /usr/bin/node ETIMEDOUT"), { |
| 556 | +code: "ETIMEDOUT", |
| 557 | +}); |
| 558 | +vi.mocked(spawnSync).mockReturnValueOnce({ |
| 559 | +pid: 0, |
| 560 | +output: [], |
| 561 | +stdout: "", |
| 562 | +stderr: "", |
| 563 | +status: null, |
| 564 | +signal: null, |
| 565 | +error: timeoutErr, |
| 566 | +}); |
| 567 | +vi.mocked(runtimeCapture.log).mockClear(); |
| 568 | + |
| 569 | +await updateCliShared.tryWriteCompletionCache(root, false); |
| 570 | + |
| 571 | +const logs = vi.mocked(runtimeCapture.log).mock.calls.map((call) => String(call[0])); |
| 572 | +expect(logs.some((line) => line.includes("timed out after 30s"))).toBe(true); |
| 573 | +expect(logs.some((line) => line.includes("openclaw completion --write-state"))).toBe(true); |
| 574 | +expect(logs.some((line) => line.includes("Error: spawnSync"))).toBe(false); |
| 575 | +}); |
| 576 | + |
552 | 577 | it("respawns into the updated package root before running post-update tasks", async () => { |
553 | 578 | const { entrypoints } = setupUpdatedRootRefresh(); |
554 | 579 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -260,6 +260,8 @@ export async function resolveGlobalManager(params: {
|
260 | 260 | } |
261 | 261 | |
262 | 262 | const COMPLETION_CACHE_WRITE_TIMEOUT_MS = 30_000; |
| 263 | +const COMPLETION_CACHE_MANUAL_REFRESH_HINT = |
| 264 | +"Shell tab-completion may be stale; refresh manually with: openclaw completion --write-state"; |
263 | 265 | |
264 | 266 | export async function tryWriteCompletionCache(root: string, jsonMode: boolean): Promise<void> { |
265 | 267 | const binPath = path.join(root, "openclaw.mjs"); |
@@ -279,15 +281,28 @@ export async function tryWriteCompletionCache(root: string, jsonMode: boolean):
|
279 | 281 | |
280 | 282 | if (result.error) { |
281 | 283 | if (!jsonMode) { |
282 | | -defaultRuntime.log(theme.warn(`Completion cache update failed: ${String(result.error)}`)); |
| 284 | +const err = result.error as NodeJS.ErrnoException; |
| 285 | +const reason = |
| 286 | +err.code === "ETIMEDOUT" |
| 287 | + ? `timed out after ${COMPLETION_CACHE_WRITE_TIMEOUT_MS / 1000}s` |
| 288 | + : String(result.error); |
| 289 | +defaultRuntime.log( |
| 290 | +theme.warn( |
| 291 | +`Completion cache update failed: ${reason}. ${COMPLETION_CACHE_MANUAL_REFRESH_HINT}`, |
| 292 | +), |
| 293 | +); |
283 | 294 | } |
284 | 295 | return; |
285 | 296 | } |
286 | 297 | |
287 | 298 | if (result.status !== 0 && !jsonMode) { |
288 | 299 | const stderr = (result.stderr ?? "").trim(); |
289 | 300 | const detail = stderr ? ` (${stderr})` : ""; |
290 | | -defaultRuntime.log(theme.warn(`Completion cache update failed${detail}.`)); |
| 301 | +defaultRuntime.log( |
| 302 | +theme.warn( |
| 303 | +`Completion cache update failed${detail}. ${COMPLETION_CACHE_MANUAL_REFRESH_HINT}`, |
| 304 | +), |
| 305 | +); |
291 | 306 | } |
292 | 307 | } |
293 | 308 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。