chenhg5/cc-connect · error
read stdout: %w
Error message
read stdout: %w
What it means
The goroutine reading the agy process's stdout hit a read error other than EOF or the benign 'file already closed' (which happens on normal cancellation). The raw OS read error is wrapped as 'read stdout: %w' and delivered as a core.EventError. It indicates the stdout pipe broke unexpectedly rather than the process finishing.
Source
Thrown at agent/antigravity/session.go:303
reader := bufio.NewReader(stdout)
buf := make([]byte, 1024)
for {
n, err := reader.Read(buf)
if n > 0 {
text := string(buf[:n])
select {
case as.events <- core.Event{Type: core.EventText, Content: text}:
case <-as.ctx.Done():
return
}
}
if err != nil {
if err != io.EOF && !strings.Contains(err.Error(), "file already closed") {
slog.Error("antigravitySession: read error", "error", err)
select {
case as.events <- core.Event{Type: core.EventError, Error: fmt.Errorf("read stdout: %w", err)}:
case <-as.ctx.Done():
}
}
return
}
}
}
func (as *antigravitySession) detectNewSessionID(preEntries map[string]bool, sendStartedAt time.Time) string {
homeDir, err := os.UserHomeDir()
if err != nil {
return ""
}
slug := antigravityProjectSlug(as.workDir)
chatsDir := filepath.Join(homeDir, ".gemini", "tmp", slug, "chats")
entries, err := os.ReadDir(chatsDir)
if err != nil {View on GitHub (pinned to 4000b2338a)
Solutions
- Check whether the agy process crashed (dmesg / OOM killer logs) and fix the underlying crash
- Verify ulimit -n and system resources are not exhausted
- Retry the turn; transient pipe errors usually disappear on rerun
- If you cancel sessions, confirm cancellation goes through ctx (which closes stdout gracefully and is filtered) rather than killing the process directly
Defensive patterns
Strategy: retry
Validate before calling
// pre-flight: ensure resources OK
if n := len(processList("agy")); n > 0 { /* prior agy still running? kill stale ones */ } Try / catch
if evt.Type == core.EventError && strings.HasPrefix(evt.Error.Error(), "read stdout:") {
slog.Warn("transient stdout read failure; retrying turn", "err", evt.Error)
// re-dispatch the turn
} Prevention
- Avoid SIGKILLing agy; cancel via session Stop/ctx so stdout close is filtered
- Raise fd limits on hosts running many sessions
- Monitor for OOM kills of the agy process
When it happens
Trigger: reader.Read on the agy stdout pipe returns a non-EOF error, e.g. the pipe descriptor is invalid, the process was killed with SIGKILL leaving a broken pipe, or an fd was closed concurrently outside the normal ctx cancellation path.
Common situations: agy process crashed hard or was OOM-killed; system resource exhaustion (fd limits); external kill of the child process; rare kernel-level pipe errors.
Related errors
- copilotSession: stdout pipe: %w
- codex app-server stdin pipe: %w
- codex app-server stdout pipe: %w
- codex app-server stderr pipe: %w
- %s write timed out
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/0afacd4aa74b1165.
Report an issue: GitHub.