-
-
Notifications
You must be signed in to change notification settings - Fork 565
Description
Summary
After upgrading to cats effect 3.6.x we've observed some apparent client connection leaks in our http4s applications. Initial experimentation perhaps point to this change to timeout being a contributing factor: #4059.
Reproducing
Cats Effect version: 3.6.3
This gist has a—somewhat—minimal reproducer. It does require http4s and a random web server available to throw a lot of requests at (here's the basic one we used). The gist uses Blaze as the client for ease of demonstration, but we've experienced the same symptoms using Ember as well.
The setup involves a client middleware that times out requests exceeding a configurable duration, historically that was implemented using timeout directly. Since upgrading to CE 3.6.x, this approach appears to cause leaked connections. Both reverting to Cats Effect 3.5.7 and re-implementing timeout using race directly resolve the issue. The withCETimeoutIncludingSleep variant that sleeps for any period after the timeout seems to avoid the leak as well.
Expected Behavior
All requests should complete without overflowing the wait queue since the number of concurrent requests (10) is less than max connections + wait queue size (10 + 3)
Actual Behavior
The client using the middleware with timeout directly throws a WaitQueueFull exception. The other client middlewares succeed.