Repository navigation
Description
Summary
Opening the plan-review page crashes the entire pi process with an unhandled write EPIPE originating from the Codex app-server provider's stdin. The pi session dies mid-tool-call (the plannotator_submit_plan tool call is written to the session log with no tool result), so it reads as a hard crash rather than a caught error.
Environment
@plannotator/pi-extension0.23.0codex-cli0.22.0 (/opt/homebrew/bin/codex, onPATH)- Node v22.19.0
- macOS (arm64)
- pi agent 0.80.6, model glm-5.2 (zai)
Stack trace
### UNCAUGHT EXCEPTION ###
Error: write EPIPE
at afterWriteDispatched (node:internal/stream_base_commons:159:15)
at writeGeneric (node:internal/stream_base_commons:150:3)
at Socket._writeGeneric (node:net:966:11)
at Socket._write (node:net:978:8)
at writeOrBuffer (node:internal/streams/writable:572:12)
at Writable.write (node:internal/streams/writable:510:10)
at CodexAppServerProcess.send (generated/ai/providers/codex-app-server.ts:442:21)
at CodexAppServerProcess.sendAndWait (codex-app-server.ts:448:12)
at CodexAppServerProcess.doStart (codex-app-server.ts:366:18)
at CodexAppServerProvider.fetchModels (codex-app-server.ts:550:7)
Root cause
startPlanReviewServer calls createPiAIRuntime(), which registers the Codex provider whenever codex is found on PATH and eagerly calls fetchModels(). That spawns the codex app-server and writes an initialize message to its stdin.
With an incompatible codex version (here codex-cli 0.22.0), the child closes its end of the pipe, so the write fails asynchronously with EPIPE. The spawned process' stdin has no error listener, so Node escalates the stream error to uncaughtException and kills the whole pi process.
The existing .catch(() => {}) on fetchModels() in server/ai-runtime.ts does not cover this, because the failure surfaces as an 'error' event on the stdin stream, not as a promise rejection.
send() only guards against a destroyed stream, which does not prevent the async EPIPE:
send(message: RpcMessage): void {
if (!this.proc?.stdin || this.proc.stdin.destroyed) return;
this.proc.stdin.write(`${JSON.stringify(message)}\n`);
}Proposed fix
Attach a no-op error listener to the child's stdin right after spawn (single choke point for every send() caller). In generated/ai/providers/codex-app-server.ts, after this.proc = proc;:
this.proc = proc;
// Swallow async EPIPE on stdin — codex may close the pipe mid-write
// (e.g. incompatible app-server version). Without this listener the
// 'error' event escalates to uncaughtException and kills the host process.
proc.stdin?.on("error", () => {});
proc.once("exit", () => {
this.handleProcessEnd(new Error("Codex app-server exited unexpectedly"));
});With the listener, the write error is handled, the process still ends cleanly via the exit/timeout paths, fetchModels() rejects and is swallowed by the existing .catch(), and pi keeps running. Verified locally: the same repro that produced the uncaught EPIPE now completes cleanly (all plan-review endpoints return 200).
Repro
- Have an incompatible
codexonPATH(codex-cli 0.22.0 reproduces it reliably). - In a pi session with the extension, write a markdown plan and call
plannotator_submit_plan. - The plan-review page opens,
createPiAIRuntimeprobes codex, and pi dies with the EPIPE above.
Activity
jash90 commentedon Jul 11, 2026
Closing — not a bug in plannotator. The EPIPE came from a stale local codex 0.22.0 (lacks the
app-serversubcommand) being first on PATH; using a current codex fixes it. Withdrawing the report.