From 29713229521ddda4a0add4a29ab8764902ec60bf Mon Sep 17 00:00:00 2001 From: MoerAI Date: Fri, 24 Apr 2026 11:13:38 +0900 Subject: [PATCH] fix(doctor): catch unexpected failures and provide actionable diagnostics (fixes #3345) --- src/cli/doctor/index.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cli/doctor/index.ts b/src/cli/doctor/index.ts index 2beef3c6b..e4c21321e 100644 --- a/src/cli/doctor/index.ts +++ b/src/cli/doctor/index.ts @@ -1,9 +1,18 @@ import type { DoctorOptions } from "./types" import { runDoctor } from "./runner" +import { EXIT_CODES } from "./constants" export async function doctor(options: DoctorOptions = { mode: "default" }): Promise { - const result = await runDoctor(options) - return result.exitCode + try { + const result = await runDoctor(options) + return result.exitCode + } catch (error) { + const message = error instanceof Error ? error.message : String(error) + console.error("\nDoctor failed unexpectedly:", message) + console.error("This may indicate memory pressure (OOM/SIGKILL) or a corrupted installation.") + console.error("Try: OMO_DISABLE_POSTHOG=1 bunx oh-my-opencode doctor --verbose\n") + return EXIT_CODES.FAILURE + } } export * from "./types"