Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async::HTTP::Client#get with a block does not appear to yield a response #170

Open
postmodern opened this issue Jul 27, 2024 · 1 comment

Comments

@postmodern
Copy link
Contributor

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)
@ioquatix
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants