{"record":{"id":"3bf57c95ddf53bc0","repo":"chenhg5/cc-connect","slug":"acp-read-closed-w","errorCode":null,"errorMessage":"acp: read closed: %w","messagePattern":"acp: read closed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/acp/rpc.go","lineNumber":74,"sourceCode":"\t\tpending: make(map[string]chan rpcOutcome),\n\t\tonNotif: onNotif,\n\t\tonReq:   onReq,\n\t}\n}\n\nfunc (t *transport) readLoop(ctx context.Context) {\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\tdefault:\n\t\t}\n\t\tline, err := t.readLine()\n\t\tif err != nil {\n\t\t\tif err != io.EOF {\n\t\t\t\tslog.Debug(\"acp: read error\", \"error\", err)\n\t\t\t}\n\t\t\tt.cancelAll(fmt.Errorf(\"acp: read closed: %w\", err))\n\t\t\treturn\n\t\t}\n\t\tif len(bytes.TrimSpace(line)) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tt.dispatchLine(line)\n\t}\n}\n\nfunc (t *transport) readLine() ([]byte, error) {\n\tline, err := t.in.ReadBytes('\\n')\n\tif err != nil {\n\t\treturn line, err\n\t}\n\treturn bytes.TrimSuffix(line, []byte(\"\\r\")), nil\n}\n\nfunc (t *transport) dispatchLine(line []byte) {","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/acp/rpc.go#L56-L92","documentation":"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.","triggerScenarios":"Thrown at agent/acp/rpc.go:74 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}