socketry / async-http

MIT License
308 stars 45 forks source link

Consider adding option to force close - killing all in-flight connections. #168

Open ioquatix opened 1 month ago

ioquatix commented 1 month ago

https://github.com/socketry/async-http/blob/8bbf377044cb1660c50f315428e3df70129cf694/lib/async/http/client.rb#L83-L90

The after hook can hang if a test fails without closing all responses:

                def after
                    @client&.close
                    @server_task&.stop
                    @bound_endpoint&.close

                    super
                end

Maybe introduce @client&.close(force = true) OR @client&.stop (force close). I'm a little worried about side effects since the connection pool may not contain all active connections.

ioquatix commented 1 month ago

You could reproduce this behaviour with a test response = client.get then raises an exception in sus.