Skip to content

v0.2.1 - a missing Codex CLI no longer crashes DSH

Choose a tag to compare

@447662 447662 released this 03 Oct 00:53
· 3 commits to main since this release

v0.2.1 — a missing Codex CLI no longer crashes DSH

The bug

On a machine without the Codex CLI installed, starting DSH with this plugin enabled killed the whole host process:

dsh: fatal uncaught exception: Error: spawn codex ENOENT
    at onErrorNT (node:internal/child_process:508:16)
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn codex',
  path: 'codex',
  spawnargs: [ 'app-server' ]

The app showed "应用无法启动或已意外停止" and could not start at all.

Why it was fatal rather than a normal error: the stdio transport's error handler called this.emit('error', error) on an EventEmitter with no 'error' listener. Node's EventEmitter rethrows in that case, and it rethrows synchronously inside a Node event handler — so the RPC route's try/catch never saw it. A plugin must never be able to do that.

The fix

  • A default 'error' listener is always installed, so emitting can no longer throw. Extra listeners still receive the same error.
  • start() now rejects instead of leaving the caller to wait out the 20s handshake timeout: the initialize request races the spawn failure, and the child is torn down on the losing path.
  • ENOENT / EACCES are described in terms of what to do:

    未找到 Codex CLI:无法执行 "codex"。请先安装 Codex CLI(npm i -g @openai/codex),或在配置里把 codexBin 指向它的完整路径

  • A synchronous throw from spawn (bad cwd, invalid args) is handled too.
  • The UI shows the reason in a banner that clears itself as soon as any RPC succeeds again.
  • test/spawn-failure-check.mjs runs against a deliberately missing binary and asserts that start() rejects with an actionable message, that nothing escapes as an unhandled rejection or uncaught exception, and that a retry still behaves. It is wired into npm run check and CI.

If you are stuck on the crashing version

The crash dialog has an escape hatch: "禁用第三方插件、备份 profile patch 并重启" — use it to boot DSH with third-party plugins disabled, then either install the Codex CLI or remove this plugin, restart, and install v0.2.1.

Install

dsh plugin --profile desktop add git+https://github.com/447662/dsh-native-codex-cli.git

Then restart DSH.

Also in this release

Carried over from v0.2.0: the plugin was renamed from dsh-codex (that name belongs to an unrelated plugin on npm and GitHub).

Requirements: DeepSeek Harness with the Web GUI, Codex CLI on PATH and logged in (codex --version), Node 18+ for the self-checks.

Full documentation: README (中文) · README (English)