chenhg5/cc-connect · error

reasonix: SSE disconnected during turn

Error message

reasonix: SSE disconnected during turn

What it means

A sentinel set by the reasonix SSE readLoop when the event stream drops while a turn is in flight: errTurn is populated so the blocked Send() unblocks with this error instead of hanging forever waiting for turn completion that will never arrive.

Source

Thrown at agent/reasonix/session.go:275

			goto retryWait
		}

		slog.Info("reasonix: SSE connected")
		s.alive.Store(true)
		backoff = 1 * time.Second // reset backoff on successful connection
		s.reconnectCount = 0      // reset reconnect count on successful connection
		s.readSSE(ctx, resp.Body)
		_ = resp.Body.Close()

		// Connection dropped; if context is still alive, reconnect
		if ctx.Err() != nil {
			s.alive.Store(false)
			return
		}
		// If a turn is in progress, unblock Send() with a reconnect error
		if s.inTurn.Load() {
			s.mu.Lock()
			s.errTurn = fmt.Errorf("reasonix: SSE disconnected during turn")
			s.mu.Unlock()
			s.emit(core.Event{Type: core.EventResult, Done: true, Error: fmt.Errorf("SSE disconnected, reconnecting")})
			s.inTurn.Store(false)
			s.turnDone <- struct{}{}
		}
		slog.Warn("reasonix: SSE connection lost, reconnecting", "backoff", backoff)

	retryWait:
		s.reconnectCount++
		if s.reconnectCount >= s.maxReconnects {
			slog.Error("reasonix: SSE reconnect limit reached, closing session", "max", s.maxReconnects)
			s.alive.Store(false)
			if s.inTurn.Load() {
				s.inTurn.Store(false)
				s.turnDone <- struct{}{}
			}
			return
		}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Resend the prompt — the loop reconnects automatically after the drop
  2. If drops are frequent, stabilize the network path to the serve instance
  3. Check serve-side logs for why SSE connections terminate
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at agent/reasonix/session.go:275 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/f0bdb1252081c1d3. Report an issue: GitHub.