async-http
async-http copied to clipboard
`Async::HTTP::Client#get` with a block does not appear to yield a response
I'm attempting to call Async::HTTP::Client#get with a block, but the block never seems to execute?
Steps To Reproduce
require 'bundler/setup'
require 'async/http'
require 'json'
endpoint = Async::HTTP::Endpoint.for('https','example.com')
client = Async::HTTP::Client.new(endpoint)
Async do
client.get('/') do |response|
puts "got here"
puts response.read
end
end
Expected Result
got here
...
Actual Result
0.09s warn: Async::Pool::Controller: Async::Pool::Controller Gardener [oid=0x67c] [ec=0x690] [pid=25251] [2024-07-26 21:28:18 -0700]
| Closing resource while still in use!
| {
| "resource": "#<Async::HTTP::Protocol::HTTP2::Client 1 requests, 0 active streams>",
| "usage": 1
| }
Versions
- ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x86_64-linux]
- async (2.14.2)
- protocol-http (0.28.1)
- async-http (0.69.0)
That's the current behaviour, the yield with response behaviour only applies to Async::HTTP::Internet as it's a higher level construct. I understand how this might be confusing, but Client is quite complex already and I'm not sure there is huge value in propagating the "convenient" interface lower. I'll certainly think about it though.
https://github.com/socketry/async-http/blob/main/lib/async/http/internet.rb#L42-L60