{"record":{"id":"f0bdb1252081c1d3","repo":"chenhg5/cc-connect","slug":"reasonix-sse-disconnected-during-turn","errorCode":null,"errorMessage":"reasonix: SSE disconnected during turn","messagePattern":"reasonix: SSE disconnected during turn","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/reasonix/session.go","lineNumber":275,"sourceCode":"\t\t\tgoto retryWait\n\t\t}\n\n\t\tslog.Info(\"reasonix: SSE connected\")\n\t\ts.alive.Store(true)\n\t\tbackoff = 1 * time.Second // reset backoff on successful connection\n\t\ts.reconnectCount = 0      // reset reconnect count on successful connection\n\t\ts.readSSE(ctx, resp.Body)\n\t\t_ = resp.Body.Close()\n\n\t\t// Connection dropped; if context is still alive, reconnect\n\t\tif ctx.Err() != nil {\n\t\t\ts.alive.Store(false)\n\t\t\treturn\n\t\t}\n\t\t// If a turn is in progress, unblock Send() with a reconnect error\n\t\tif s.inTurn.Load() {\n\t\t\ts.mu.Lock()\n\t\t\ts.errTurn = fmt.Errorf(\"reasonix: SSE disconnected during turn\")\n\t\t\ts.mu.Unlock()\n\t\t\ts.emit(core.Event{Type: core.EventResult, Done: true, Error: fmt.Errorf(\"SSE disconnected, reconnecting\")})\n\t\t\ts.inTurn.Store(false)\n\t\t\ts.turnDone <- struct{}{}\n\t\t}\n\t\tslog.Warn(\"reasonix: SSE connection lost, reconnecting\", \"backoff\", backoff)\n\n\tretryWait:\n\t\ts.reconnectCount++\n\t\tif s.reconnectCount >= s.maxReconnects {\n\t\t\tslog.Error(\"reasonix: SSE reconnect limit reached, closing session\", \"max\", s.maxReconnects)\n\t\t\ts.alive.Store(false)\n\t\t\tif s.inTurn.Load() {\n\t\t\t\ts.inTurn.Store(false)\n\t\t\t\ts.turnDone <- struct{}{}\n\t\t\t}\n\t\t\treturn\n\t\t}","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/reasonix/session.go#L257-L293","documentation":"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.","triggerScenarios":"Thrown at agent/reasonix/session.go:275 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Resend the prompt — the loop reconnects automatically after the drop","If drops are frequent, stabilize the network path to the serve instance","Check serve-side logs for why SSE connections terminate"],"exampleFix":null,"handlingStrategy":"retry","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"}