chenhg5/cc-connect · error

%s

Error message

%s

What it means

An event payload in the gemini readLoop teardown: when the gemini process exits non-zero with non-empty stderr, the trimmed text is emitted as core.EventError via fmt.Errorf("%s", ...), surfacing Gemini CLI's own crash message.

Source

Thrown at agent/gemini/session.go:218

		defer cancel()
		gs.readLoop(ctx, cmd, stdout, &stderrBuf, append(imageRefs, fileRefs...))
	}()

	return nil
}

func (gs *geminiSession) readLoop(ctx context.Context, cmd *exec.Cmd, stdout io.ReadCloser, stderrBuf *bytes.Buffer, tempImages []string) {
	defer gs.wg.Done()
	defer func() {
		// Clean up temp image files
		for _, f := range tempImages {
			os.Remove(f)
		}
		if err := cmd.Wait(); err != nil {
			stderrMsg := strings.TrimSpace(stderrBuf.String())
			if stderrMsg != "" {
				slog.Error("geminiSession: process failed", "error", err, "stderr", stderrMsg)
				evt := core.Event{Type: core.EventError, Error: fmt.Errorf("%s", stderrMsg)}
				select {
				case gs.events <- evt:
				case <-gs.ctx.Done():
					return
				}
			}
		}
	}()

	// Unblock scanner if context is canceled
	go func() {
		<-ctx.Done()
		stdout.Close()
	}()

	scanner := bufio.NewScanner(stdout)
	scanner.Buffer(make([]byte, 0, 64*1024), 10*1024*1024)

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Read the stderr text for Gemini's failure reason (auth, quota, network)
  2. Fix the reported cause and resend the prompt
  3. Run gemini manually to reproduce persistent failures
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at agent/gemini/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/26a0f47cc91fa74f. Report an issue: GitHub.