{"record":{"id":"b92b0fba68b4277f","repo":"chenhg5/cc-connect","slug":"s-b92b0f","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/opencode/session.go","lineNumber":234,"sourceCode":"\tif err := scanner.Err(); err != nil {\n\t\tslog.Error(\"opencodeSession: scanner error\", \"error\", err)\n\t\tevt := core.Event{Type: core.EventError, Error: fmt.Errorf(\"read stdout: %w\", err)}\n\t\tselect {\n\t\tcase s.events <- evt:\n\t\tcase <-s.ctx.Done():\n\t\t\treturn\n\t\t}\n\t\treturn\n\t}\n\n\tstderrMsg := stderrBuf.String()\n\tif stderrMsg != \"\" {\n\t\tslog.Error(\"opencodeSession: process error\", \"stderr\", truncate(stderrMsg, 500))\n\t\tif strings.Contains(stderrMsg, \"Session not found\") {\n\t\t\ts.chatID.Store(\"\")\n\t\t\tslog.Warn(\"opencodeSession: cleared stale session ID\")\n\t\t}\n\t\tevt := core.Event{Type: core.EventError, Error: fmt.Errorf(\"%s\", stderrMsg)}\n\t\tselect {\n\t\tcase s.events <- evt:\n\t\tcase <-s.ctx.Done():\n\t\t}\n\t\treturn\n\t}\n\n\t// Check if we received compaction_continue before readLoop ended.\n\t// If so, OpenCode will continue with a new turn - do NOT send EventResult.\n\t// The subsequent process will send its own EventResult when it finishes.\n\tif s.expectingContinue.Load() {\n\t\tslog.Info(\"opencodeSession: readLoop ended after compaction_continue, skipping EventResult\", \"session_id\", s.CurrentSessionID())\n\t\ts.expectingContinue.Store(false)\n\t\treturn\n\t}\n\n\tslog.Debug(\"opencodeSession: readLoop complete, sending fallback EventResult\", \"session_id\", s.CurrentSessionID())\n\ts.sendEventResult()","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/opencode/session.go#L216-L252","documentation":"Wraps a bufio.Scanner error after the opencode stdout read loop: reading the CLI's JSON stream failed mid-turn (broken pipe after process death, or oversized lines). Emitted as EventError so the user sees the failed turn.","triggerScenarios":"Thrown at agent/opencode/session.go:234 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check whether the opencode process crashed (see stderr events)","Retry — transient stream breakage occurs under load","Report persistent oversized-line failures upstream"],"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"}