lib/httpx/session.rb in httpx-1.1.0 vs lib/httpx/session.rb in httpx-1.1.1

- old
+ new

@@ -258,10 +258,12 @@ def init_connection(type, uri, options) connection = options.connection_class.new(type, uri, options) connection.on(:open) do emit(:connection_opened, connection.origin, connection.io.socket) # only run close callback if it opened - connection.on(:close) { emit(:connection_closed, connection.origin, connection.io.socket) } + end + connection.on(:close) do + emit(:connection_closed, connection.origin, connection.io.socket) if connection.used? end catch(:coalesced) do pool.init_connection(connection, options) connection end