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:
parent
b18dfb474a
commit
569de4cd23
1 changed files with 1 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue