The chat Hub's Shutdown() only closed the done channel and returned immediately, racing against goleak.VerifyNone in TestHub_*. Worse, the broadcast saturation path spawned a fire-and-forget goroutine to send on the unregister channel, which could leak if Run() exited mid-flight. Fix: - Add `stopped` channel closed by Run() on exit; Shutdown() waits on it. - Buffer `unregister` (256) and replace the anonymous goroutine with a non-blocking select. Worst case the client is reaped on its next failed broadcast attempt. - handler_messages_test.go's setupTestHandler started a Hub but never shut it down, leaking Run() goroutines into the hub_test.go run that followed. Register t.Cleanup(hub.Shutdown) and close the gorm sqlite connection too — the connectionOpener goroutine was the secondary leak. |
||
|---|---|---|
| .. | ||
| benchmark_test.go | ||
| client.go | ||
| handler.go | ||
| handler_calls.go | ||
| handler_history.go | ||
| handler_messages.go | ||
| handler_messages_test.go | ||
| handler_realtime.go | ||
| handler_realtime_test.go | ||
| handler_rooms.go | ||
| hub.go | ||
| hub_test.go | ||
| messages.go | ||
| permissions.go | ||
| presence_service.go | ||
| presence_service_test.go | ||
| rate_limiter.go | ||
| rate_limiter_test.go | ||