fix(httpapi): detect ws client disconnect via CloseRead to prevent subscriber leak

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMHQTtnQtQqL8muAXHr9kd
This commit is contained in:
2026-07-01 18:47:54 +07:00
parent 9ec6acd414
commit 4c57848c35
3 changed files with 74 additions and 1 deletions
+7
View File
@@ -45,6 +45,13 @@ func (h *Hub) Unsubscribe(taskID, id int64) {
}
}
// SubscriberCount returns the number of active subscribers for a task (for tests/metrics).
func (h *Hub) SubscriberCount(taskID int64) int {
h.mu.Lock()
defer h.mu.Unlock()
return len(h.subs[taskID])
}
func (h *Hub) Publish(ev Event) {
h.mu.Lock()
defer h.mu.Unlock()