mirror of
https://github.com/navidrome/navidrome.git
synced 2026-06-19 07:37:15 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user