Root cause: Broadcast() and Push() launched multiple goroutines writing to the same websocket.Conn simultaneously. Gorilla websocket does not support concurrent WriteMessage/WriteJSON. Fix: add connMu sync.Map (*websocket.Conn → *sync.Mutex) to WSManager. Each WriteJSON now goes through writeWithLock() which acquires the per-conn mutex. Unregister() also acquires the lock before Close() to prevent write/close races. No functional changes to API surface. |
||
|---|---|---|
| .. | ||
| client | ||
| cmd/zhiyid | ||
| internal | ||
| proto | ||
| static | ||
| go.mod | ||
| go.sum | ||
| integration_test.go | ||
| zhiyid-new | ||