chenhg5/cc-connect · error
acp: read closed: %w
Error message
acp: read closed: %w
What it means
Raised inside the transport readLoop when reading a line from the agent's stdout fails (including normal io.EOF at process exit). It is propagated to cancel all pending RPC calls; callers see their outstanding requests fail. EOF is expected at shutdown; non-EOF indicates the pipe broke or the process died unexpectedly.
Source
Thrown at agent/acp/rpc.go:74
pending: make(map[string]chan rpcOutcome),
onNotif: onNotif,
onReq: onReq,
}
}
func (t *transport) readLoop(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
default:
}
line, err := t.readLine()
if err != nil {
if err != io.EOF {
slog.Debug("acp: read error", "error", err)
}
t.cancelAll(fmt.Errorf("acp: read closed: %w", err))
return
}
if len(bytes.TrimSpace(line)) == 0 {
continue
}
t.dispatchLine(line)
}
}
func (t *transport) readLine() ([]byte, error) {
line, err := t.in.ReadBytes('\n')
if err != nil {
return line, err
}
return bytes.TrimSuffix(line, []byte("\r")), nil
}
func (t *transport) dispatchLine(line []byte) {View on GitHub (pinned to 4000b2338a)
Solutions
- If the error is EOF after Close(), it is normal teardown and can be ignored
- For non-EOF errors, check whether the agent process crashed — look for a preceding EventError with its stderr
- Avoid issuing new RPC calls after this error; the transport is dead and must be re-spawned
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at agent/acp/rpc.go:74 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/3bf57c95ddf53bc0.
Report an issue: GitHub.