{"record":{"id":"ab6bdf91d5540e53","repo":"chenhg5/cc-connect","slug":"antigravitysession-stdout-pipe-w","errorCode":null,"errorMessage":"antigravitySession: stdout pipe: %w","messagePattern":"antigravitySession: stdout pipe: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/antigravity/session.go","lineNumber":189,"sourceCode":"\n\tslog.Debug(\"antigravitySession: launching\", \"resume\", isResume, \"args\", core.RedactArgs(args))\n\tcmd := exec.CommandContext(ctx, as.cmd, args...)\n\tcmd.WaitDelay = 1 * time.Second\n\tcmd.Dir = as.workDir\n\tenv := os.Environ()\n\tif len(as.extraEnv) > 0 {\n\t\tenv = core.MergeEnv(env, as.extraEnv)\n\t}\n\tif as.permissionBridge != nil {\n\t\tenv = core.MergeEnv(env, as.permissionBridge.Env())\n\t}\n\tcmd.Env = env\n\n\t// Keep stdin disconnected: agy --print consumes piped stdin to EOF before\n\t// processing the prompt, so an open pipe would deadlock the turn.\n\tstdout, err := cmd.StdoutPipe()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"antigravitySession: stdout pipe: %w\", err)\n\t}\n\n\tvar stderrBuf bytes.Buffer\n\tcmd.Stderr = &stderrBuf\n\n\tif err := cmd.Start(); err != nil {\n\t\treturn fmt.Errorf(\"antigravitySession: start: %w\", err)\n\t}\n\n\tstarted = true\n\tas.wg.Add(1)\n\tgo func() {\n\t\tdefer cancel()\n\t\tas.readLoop(ctx, cmd, stdout, &stderrBuf, append(imageRefs, fileRefs...), preEntries, time.Now())\n\t}()\n\n\treturn nil\n}","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/antigravity/session.go#L171-L207","documentation":"Send wraps errors from cmd.StdoutPipe(), which obtains the pipe used to stream the agy process's stdout. This fails only before the process starts — it indicates an OS-level pipe resource error and is practically rare.","triggerScenarios":"cmd.StdoutPipe() returning an error when preparing the agy --print command: fd exhaustion (EMFILE) or an internal os/exec state problem (e.g. Stdout already set, though here it is controlled by the library).","commonSituations":"System has exhausted file descriptors from many concurrent sessions/processes; running under strict rlimit configurations.","solutions":["Check the wrapped cause (%w); 'too many open files' means raise ulimit -n or reduce concurrent sessions.","Audit for fd leaks in long-running cc-connect processes (lsof -p <pid> | wc -l).","Restart the daemon if fd usage is leaked.","If persistent under rlimits, lower configured concurrent session counts."],"exampleFix":"// before\n$ ulimit -n\n256\n// after\n$ ulimit -n 1024 && cc-connect start","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := session.Send(...); err != nil && strings.Contains(err.Error(), \"stdout pipe\") {\n    // wait briefly and retry once; else surface fd-limit remediation\n}","preventionTips":["Raise ulimit -n for the cc-connect process.","Monitor fd usage of long-running daemons (lsof | wc -l).","Cap configured concurrent agent sessions below the fd budget."],"tags":["go","process","file-descriptor","antigravity"],"backgroundTag":"file-open-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}