veza/veza-backend-api/internal/websocket/chat
senke 87e1e0a5ab fix(backend): synchronous Hub.Shutdown to eliminate goleak failures
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.
2026-04-14 11:44:27 +02:00
..
benchmark_test.go v0.9.8 2026-03-06 19:13:16 +01:00
client.go feat(chat): Sprint 2 -- WebSocket hub, client, message types, route 2026-02-22 20:41:39 +01:00
handler.go v0.9.6 2026-03-06 10:29:30 +01:00
handler_calls.go feat(chat): Sprint 3 -- message handlers, real-time features, permissions 2026-02-22 20:43:44 +01:00
handler_history.go v0.9.7 2026-03-06 18:52:08 +01:00
handler_messages.go feat(v0.10.6): Livestreaming basique F471-F476 2026-03-10 10:21:57 +01:00
handler_messages_test.go fix(backend): synchronous Hub.Shutdown to eliminate goleak failures 2026-04-14 11:44:27 +02:00
handler_realtime.go v0.9.6 2026-03-06 10:29:30 +01:00
handler_realtime_test.go test(chat): Sprint 5 -- unit tests, E2E tests, feature parity validation 2026-02-22 20:49:32 +01:00
handler_rooms.go feat(chat): Sprint 3 -- message handlers, real-time features, permissions 2026-02-22 20:43:44 +01:00
hub.go fix(backend): synchronous Hub.Shutdown to eliminate goleak failures 2026-04-14 11:44:27 +02:00
hub_test.go v0.9.8 2026-03-06 19:13:16 +01:00
messages.go v0.9.7 2026-03-06 18:52:08 +01:00
permissions.go feat(v0.10.6): Livestreaming basique F471-F476 2026-03-10 10:21:57 +01:00
presence_service.go feat(chat): Redis rate limiter, persistent presence, PostgreSQL full-text search 2026-02-22 21:17:51 +01:00
presence_service_test.go feat(chat): Redis rate limiter, persistent presence, PostgreSQL full-text search 2026-02-22 21:17:51 +01:00
rate_limiter.go feat(v0.10.6): Livestreaming basique F471-F476 2026-03-10 10:21:57 +01:00
rate_limiter_test.go feat(chat): Redis rate limiter, persistent presence, PostgreSQL full-text search 2026-02-22 21:17:51 +01:00