chenhg5/cc-connect · error
wps-agentspace: write buffer full
Error message
wps-agentspace: write buffer full
What it means
writeJSON pushes the serialized frame onto p.writeCh, a bounded channel drained by writeLoop; if the buffer is full it gives up immediately with this error instead of blocking. It means the single writer goroutine cannot keep up or has stopped (e.g. the connection is dead and writeLoop exited).
Source
Thrown at platform/wps-agentspace/wpsagentspace.go:662
frame := wsFrame{
Event: event,
}
jsonData, err := json.Marshal(data)
if err != nil {
return fmt.Errorf("wps-agentspace: marshal: %w", err)
}
frame.Data = jsonData
raw, err := json.Marshal(frame)
if err != nil {
return fmt.Errorf("wps-agentspace: marshal frame: %w", err)
}
select {
case p.writeCh <- raw:
return nil
default:
return fmt.Errorf("wps-agentspace: write buffer full")
}
}
// writeLoop serializes all WebSocket writes.
func (p *Platform) writeLoop(conn *websocket.Conn) {
for msg := range p.writeCh {
if p.stopped.Load() {
return
}
// msg is already JSON-encoded bytes from writeJSON
if err := conn.WriteMessage(websocket.TextMessage, msg.([]byte)); err != nil {
slog.Error("wps-agentspace: write error", "error", err)
return
}
}
}
// --- Crypto utilities ---View on GitHub (pinned to 4000b2338a)
Solutions
- Check whether the WebSocket connection is still alive and writeLoop is running; reconnect if the connection dropped
- Increase the writeCh buffer capacity if legitimate throughput exceeds the current size
- Reduce send frequency (e.g. throttle sendTyping heartbeats)
- Treat this error as a signal to tear down and re-establish the connection
Defensive patterns
Strategy: retry
Validate before calling
if p.writeCh == nil || !p.connected() { return errors.New("not connected") } Try / catch
if err := p.sendText(chatID, text); err != nil { if strings.Contains(err.Error(), "write buffer full") { time.Sleep(backoff); return p.sendText(chatID, text) } } Prevention
- Monitor writeLoop liveness and reconnect on stall
- Size writeCh generously for expected burst traffic
- Throttle typing indicators and heartbeats
- Treat buffer-full as a health signal to reset the connection
When it happens
Trigger: Sending more WebSocket frames than writeLoop drains, or writeLoop has exited (connection closed) leaving messages to fill the buffer; called from sendInit, heartbeatLoop, handleFrame, sendText, sendTyping.
Common situations: Network stall or dropped WebSocket connection causes writes to block in the websocket library, backing up writeCh; bursts of typing indicators plus messages overflow the buffer.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- wecom-ws: ack timeout
- cloud_web: ws_url or base_url is required for websocket tran
- cloud_web: parse register_ack: %w
- cloud_web: expected register_ack, got %q
- cloud_web: register rejected: %s
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/f5201ce6a46879e1.
Report an issue: GitHub.