From ec37859fbc8b31e0d31f24b818541cc270d41ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deluan=20Quint=C3=A3o?= Date: Wed, 6 May 2026 11:03:11 -0400 Subject: [PATCH] fix(test): prevent flaky deadlock in throttle backlog test (#5474) The `held` channel in `runTwoRequests` was unbuffered, creating a race condition with the `select/default` send in the handler. Under CI load (slow runner, -race, -shuffle=on), the handler goroutine could reach the select before the test goroutine blocked on `<-held`, causing the send to silently fall through to `default` and deadlocking both goroutines permanently. Buffer the channel (capacity 1) so the send always succeeds regardless of goroutine scheduling order. --- server/throttle_backlog_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/throttle_backlog_test.go b/server/throttle_backlog_test.go index eb181b4ce..4d8567db5 100644 --- a/server/throttle_backlog_test.go +++ b/server/throttle_backlog_test.go @@ -209,7 +209,7 @@ var _ = Describe("ThrottleBacklog", func() { // runTwoRequests sends two concurrent requests through a throttled router. The // first request holds the token until the second has been dispatched. func runTwoRequests(m func(http.Handler) http.Handler) (firstStatus, secondStatus int) { - held := make(chan struct{}) + held := make(chan struct{}, 1) release := make(chan struct{}) r := chi.NewRouter() r.Use(m)