mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-19 14:19:16 -04:00
fix(realtime): keep the WebRTC sendLoop alive when one event send fails
A failed SendText on the oai-events data channel exited the sender goroutine, so a single dropped event (e.g. one over the negotiated SCTP max-message-size) tore down the session and silently dropped every subsequent event. Log and skip the offending event instead and keep draining; a genuinely dead transport is still handled by the closed / connection-state path. Assisted-by: Claude:claude-opus-4-8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
@@ -113,8 +113,13 @@ func (t *WebRTCTransport) sendLoop() {
|
||||
return
|
||||
}
|
||||
if err := t.dc.SendText(string(data)); err != nil {
|
||||
xlog.Error("data channel send failed", "error", err)
|
||||
return
|
||||
// Drop just this event and keep the loop alive: a single
|
||||
// failed send (e.g. an event over the negotiated SCTP
|
||||
// max-message-size) must not tear down the session and
|
||||
// silently drop every subsequent event. A genuinely dead
|
||||
// transport is handled by the <-t.closed case.
|
||||
xlog.Error("data channel send failed, dropping event", "error", err)
|
||||
continue
|
||||
}
|
||||
case <-t.closed:
|
||||
// Drain any remaining queued events before exiting
|
||||
@@ -122,7 +127,8 @@ func (t *WebRTCTransport) sendLoop() {
|
||||
select {
|
||||
case data := <-t.outEvents:
|
||||
if err := t.dc.SendText(string(data)); err != nil {
|
||||
return
|
||||
xlog.Error("data channel send failed while draining, dropping event", "error", err)
|
||||
continue
|
||||
}
|
||||
default:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user