chenhg5/cc-connect · error
read stdout: %w
Error message
read stdout: %w
What it means
Wrapped bufio.Scanner error emitted by the opencode session's stdout read loop when the JSON-lines stream from the opencode process terminates abnormally (I/O failure, buffer overflow, or process death) rather than clean EOF; surfaced to the platform as an EventError.
Source
Thrown at agent/opencode/session.go:218
for scanner.Scan() {
line := scanner.Text()
if line == "" {
continue
}
var raw map[string]any
if err := json.Unmarshal([]byte(line), &raw); err != nil {
slog.Debug("opencodeSession: non-JSON line", "line", line)
continue
}
s.handleEvent(raw)
}
if err := scanner.Err(); err != nil {
slog.Error("opencodeSession: scanner error", "error", err)
evt := core.Event{Type: core.EventError, Error: fmt.Errorf("read stdout: %w", err)}
select {
case s.events <- evt:
case <-s.ctx.Done():
return
}
return
}
stderrMsg := stderrBuf.String()
if stderrMsg != "" {
slog.Error("opencodeSession: process error", "stderr", truncate(stderrMsg, 500))
if strings.Contains(stderrMsg, "Session not found") {
s.chatID.Store("")
slog.Warn("opencodeSession: cleared stale session ID")
}
evt := core.Event{Type: core.EventError, Error: fmt.Errorf("%s", stderrMsg)}
select {
case s.events <- evt:View on GitHub (pinned to 4000b2338a)
Solutions
- Log and forward the error event so the user sees the agent stream died
- Check whether the opencode process exited (non-zero exit, OOM, crash) and restart the session if configured
- Raise bufio.Scanner buffer size if lines exceed the 64KB default
- Ensure the process is reaped and the session marked closed so the next turn starts fresh
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at agent/opencode/session.go:218 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/bcb197d237b7509a.
Report an issue: GitHub.