{"record":{"id":"db797ccfa39e2a90","repo":"chenhg5/cc-connect","slug":"acp-probe-stdout-pipe-w","errorCode":null,"errorMessage":"acp: probe stdout pipe: %w","messagePattern":"acp: probe stdout pipe: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/acp/list_sessions.go","lineNumber":81,"sourceCode":"\tUpdatedAt string `json:\"updatedAt,omitempty\"`\n}\n\n// probeSpawn launches `<cmd> <args...>`, sets up a JSON-RPC transport\n// and starts its readLoop. The caller owns the returned `teardown`\n// func and must invoke it to reap the child process.\nfunc (a *Agent) probeSpawn(ctx context.Context, cwd string) (*transport, *bytes.Buffer, func(), error) {\n\tallArgs := append(append([]string{}, a.cliExtraArgs...), a.args...)\n\tcmd := exec.CommandContext(ctx, a.cmd, allArgs...)\n\tcmd.Dir = cwd\n\tcmd.Env = core.MergeEnv(os.Environ(), a.extraEnv)\n\n\tstdin, err := cmd.StdinPipe()\n\tif err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"acp: probe stdin pipe: %w\", err)\n\t}\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"acp: probe stdout pipe: %w\", err)\n\t}\n\tvar stderrBuf bytes.Buffer\n\tcmd.Stderr = io.MultiWriter(&stderrBuf)\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn nil, nil, nil, fmt.Errorf(\"acp: probe start %s: %w\", a.cmd, err)\n\t}\n\n\t// The server-request handler needs to reference `tr` itself in order\n\t// to respondError; declare via var so the closure captures the\n\t// variable (which is assigned to a *transport below) rather than an\n\t// uninitialised copy.\n\tvar tr *transport\n\ttr = newTransport(stdout, stdin,\n\t\tfunc(method string, _ json.RawMessage) {\n\t\t\tslog.Debug(\"acp-probe: notification\", \"method\", method)\n\t\t},\n\t\tfunc(_ string, id json.RawMessage, _ json.RawMessage) {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/acp/list_sessions.go#L63-L99","documentation":"Same failure family as error 27 but on the output side: probeSpawn's cmd.StdoutPipe() call failed while preparing to launch the ACP agent for a ListSessions probe. It indicates an OS-level pipe allocation failure (fd exhaustion) before the process starts; ListSessions aborts with this error.","triggerScenarios":"cmd.StdoutPipe() returns an error in probeSpawn — file-descriptor exhaustion (too many open fds), pipe allocation limits hit, or OS resource pressure after many concurrent agent probes.","commonSituations":"Daemons with fd leaks; low ulimit -n; containers with restrictive resource limits; parallel session listing against many agents.","solutions":["Raise the fd limit (ulimit -n / systemd LimitNOFILE) and restart the daemon.","Audit for leaked fds (`ls /proc/<pid>/fd | wc -l`) and fix or restart the leaking component.","Serialize or reduce concurrent probeSpawn/ListSessions calls.","Increase container nofile/pipe limits if running under Docker/Kubernetes."],"exampleFix":"// before\n$ ulimit -n\n256\n// after\n$ ulimit -n 65536   # or systemd LimitNOFILE=65536","handlingStrategy":"retry","validationCode":"var lim syscall.Rlimit\nsyscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)\nif lim.Cur < 2048 {\n    return errors.New(\"fd limit too low: StdoutPipe allocation may fail during acp probe\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"probe stdout pipe\") {\n    slog.Warn(\"acp: stdout pipe allocation failed; retrying with backoff\", \"err\", err)\n    select {\n    case <-time.After(backoff):\n    case <-ctx.Done():\n        return ctx.Err()\n    }\n    // retry ListSessions\n}","preventionTips":["Same fd-hygiene as stdin pipe failures: raise RLIMIT_NOFILE","Check /proc/<pid>/fd count growth for leaks","Avoid spawning many probes in parallel","Increase container nofile limits"],"tags":["acp","os","file-descriptors","process-spawn"],"backgroundTag":"resource-exhaustion","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"}