fix(ws): wire topicLimiter into hand-rolled test hubs

newEmitTestHub and NewHubForTest built raw Hub literals without the
topic rate limiter, so deliverBroadcast panicked on a nil receiver and
TestEmitEvents_ChannelEvent_CallsBroadcastToChannel could never pass.
CI never surfaced it because the pipeline died at govulncheck first.
Wire the limiter exactly as NewHub does; no production nil-guard, since
a nil limiter in production would silently disable rate limiting.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
J3vb
2026-07-18 11:45:30 +02:00
co-authored by Claude Fable 5
parent c7b49ee1fc
commit 522003ebe3
2 changed files with 4 additions and 2 deletions
+1
View File
@@ -34,6 +34,7 @@ func newEmitTestHub() *Hub {
pubsub: NewPubSub(),
replayBuf: NewEventRingBuffer(100),
voiceKeyHolders: make(map[int64]int64),
topicLimiter: NewTopicRateLimiter(topicRateLimitPerSecond, time.Second),
}
}
+3 -2
View File
@@ -93,8 +93,9 @@ func (p *LiveKitProcess) SetProcessStoppedForTest() {
// NewHubForTest creates a minimal Hub with no DB or limiter for webhook testing.
func NewHubForTest() *Hub {
return &Hub{
clients: make(map[int64]*Client),
pubsub: NewPubSub(),
clients: make(map[int64]*Client),
pubsub: NewPubSub(),
topicLimiter: NewTopicRateLimiter(topicRateLimitPerSecond, time.Second),
}
}