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.
Summary
After upgrading to cats effect
3.6.xwe've observed some apparent client connection leaks in ourhttp4sapplications. Initial experimentation perhaps point to this change totimeoutbeing a contributing factor: #4059.Reproducing
Cats Effect version:
3.6.3This gist has a—somewhat—minimal reproducer. It does require
http4sand 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
timeoutdirectly. Since upgrading to CE3.6.x, this approach appears to cause leaked connections. Both reverting to Cats Effect3.5.7and re-implementingtimeoutusingracedirectly resolve the issue. ThewithCETimeoutIncludingSleepvariant that sleeps for any period after thetimeoutseems 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
timeoutdirectly throws aWaitQueueFullexception. The other client middlewares succeed.