chenhg5/cc-connect · error
%s read response: %w
Error message
%s read response: %w
What it means
rpcRequestOverIO reads newline-delimited JSON-RPC responses from the codex app-server; when ReadBytes fails (EOF because the process exited, or a pipe I/O error) before a matching response arrives, it returns an error prefixed with the RPC method name. This means the app-server died or closed its stdout before answering the request, not that the response was malformed.
Source
Thrown at agent/codex/session.go:736
return strings.TrimSpace(resp.Config.Model), normalizeRuntimeReasoningEffort(stringValue(resp.Config.ModelReasoningEffort)), nil
}
func rpcRequestOverIO(stdin io.Writer, reader *bufio.Reader, id int64, method string, params any, out any) error {
payload := map[string]any{
"jsonrpc": "2.0",
"id": id,
"method": method,
"params": params,
}
if err := writeRPCMessage(stdin, payload); err != nil {
return err
}
for {
line, err := reader.ReadBytes('\n')
if err != nil {
return fmt.Errorf("%s read response: %w", method, err)
}
var probe map[string]json.RawMessage
if err := json.Unmarshal(bytes.TrimSpace(line), &probe); err != nil {
continue
}
if _, ok := probe["id"]; !ok {
continue
}
var resp rpcResponseEnvelope
if err := json.Unmarshal(bytes.TrimSpace(line), &resp); err != nil {
continue
}
respID, ok := rpcIDToInt64(resp.ID)
if !ok || respID != id {
continue
}View on GitHub (pinned to 4000b2338a)
Solutions
- Run the codex binary manually (`codex app-server` or the configured subcommand) to see why it exits — startup crashes are the usual cause.
- Update the Codex CLI to a version that supports app-server JSON-RPC mode.
- Check `command` and args in the codex agent config for typos or flags the installed version rejects.
- Check authentication (`codex login`) — some versions exit when credentials are missing.
- Capture the app-server's stderr output to identify the exit reason; retry once transient resource pressure is resolved.
Example fix
// before: old codex build exits on the app-server subcommand $ codex --version codex-cli 0.1.0 // unsupported // after $ npm i -g @openai/codex && codex --version codex-cli 0.9.0
Defensive patterns
Strategy: retry
Validate before calling
// verify the app-server subcommand starts and answers before RPC use
cmd := exec.Command(cfg.Command, "app-server", "--help")
if err := cmd.Run(); err != nil {
return fmt.Errorf("codex app-server unsupported or failing: %w", err)
} Type guard
func isRPCReadError(err error, method string) bool {
return err != nil && strings.HasPrefix(err.Error(), method+" read response:")
} Try / catch
resp, err := rpcRequestOverIO(stdin, stdout, ctx, "initialize", params, &out)
if isRPCReadError(err, "initialize") {
// app-server exited early; capture stderr and retry with a fresh process
slog.Error("app-server died during RPC", "err", err, "stderr", stderr.String())
} Prevention
- Keep the Codex CLI updated to a version that supports app-server JSON-RPC
- Capture and log the child's stderr to diagnose early exits
- Authenticate codex before launching app-server sessions
- Apply request timeouts that allow the process time to answer before teardown
When it happens
Trigger: reader.ReadBytes('\n') returns io.EOF or another read error inside rpcRequestOverIO while waiting for a reply to a method such as an initialization or config RPC issued by loadCodexRuntimeConfig.
Common situations: The codex app-server crashes or exits during startup (bad args, missing auth); the binary version does not support app-server mode and exits immediately; a request timeout in the caller kills the process while the RPC is pending; pipe broken by process kill.
Related errors
- codex app-server resume returned empty thread id
- codex app-server start returned empty thread id
- codex app-server turn/start: %w
- turn failed (no details)
- %s
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/ffb7a76c0bb9a716.
Report an issue: GitHub.