diff options
| author | Aiden Cline <[email protected]> | 2026-01-12 13:47:25 -0600 |
|---|---|---|
| committer | Aiden Cline <[email protected]> | 2026-01-12 13:47:25 -0600 |
| commit | e47f3831375f96acaf69b081deb6b32ab4d403d0 (patch) | |
| tree | 812a0ef47b3ecdeb9cbc368d165d6198a3db1bfd | |
| parent | cd56845dce07d418bed853cb16ebeea82107b79f (diff) | |
| download | opencode-e47f3831375f96acaf69b081deb6b32ab4d403d0.tar.gz opencode-e47f3831375f96acaf69b081deb6b32ab4d403d0.zip | |
core: improve error handling for built-in plugin installation failures
| -rw-r--r-- | packages/opencode/src/plugin/index.ts | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/packages/opencode/src/plugin/index.ts b/packages/opencode/src/plugin/index.ts index f57b46a35..b0c9eee2c 100644 --- a/packages/opencode/src/plugin/index.ts +++ b/packages/opencode/src/plugin/index.ts @@ -8,6 +8,8 @@ import { BunProc } from "../bun" import { Instance } from "../project/instance" import { Flag } from "../flag/flag" import { CodexAuthPlugin } from "./codex" +import { Session } from "../session" +import { NamedError } from "@opencode-ai/util/error" export namespace Plugin { const log = Log.create({ service: "plugin" }) @@ -54,8 +56,21 @@ export namespace Plugin { const version = lastAtIndex > 0 ? plugin.substring(lastAtIndex + 1) : "latest" const builtin = BUILTIN.some((x) => x.startsWith(pkg + "@")) plugin = await BunProc.install(pkg, version).catch((err) => { - if (builtin) return "" - throw err + if (!builtin) throw err + + const message = err instanceof Error ? err.message : String(err) + log.error("failed to install builtin plugin", { + pkg, + version, + error: message, + }) + Bus.publish(Session.Event.Error, { + error: new NamedError.Unknown({ + message: `Failed to install built-in plugin ${pkg}@${version}: ${message}`, + }).toObject(), + }) + + return "" }) if (!plugin) continue } |
