Closed mperham closed 2 years ago
Sorry, I'm not quite sure what is going on here, are you saying the API in v4 broke in a minor release, or broke between v3 and v4 and the documentation/behaviour could be improved?
I was using connect without a block in v3. It was working fine. I upgraded to v4 and it broke with the backtrace above. I switched to the block form and it solved the problem. Ergo I assume the major version bump was for the new style of usage but I was surprised that the old style wasn't explicitly broken to make the upgrade path clearer for users..
Okay, I see how this could be confusing.
The error message "No async task available!" tells you what is wrong but not how to rectify it.
It gave me an idea, maybe Ruby exceptions should include a URL field by default, which allows us to link them through to more documentation. It seems logical to me.
But short of that, what you need to do is use an Async do ... end
block. Generally, for APIs, this is not needed since you'd probably be doing a set of operations in a "single transaction". That being said I completely agree that it's non-obvious what to do.
So, I'll try to fix this by documentation, some more examples, etc.
Ran into this again today. Upgraded all my gems and got the same behavior. Googled and found I was the first hit.
No async task available!
/Users/mperham/.gem/ruby/3.0.3/gems/async-1.30.3/lib/async/task.rb:189:in `current'
/Users/mperham/.gem/ruby/3.0.3/gems/async-io-1.33.0/lib/async/io/host_endpoint.rb:55:in `connect'
/Users/mperham/.gem/ruby/3.0.3/gems/async-io-1.33.0/lib/async/io/ssl_endpoint.rb:92:in `connect'
/Users/mperham/.gem/ruby/3.0.3/gems/async-http-0.56.6/lib/async/http/endpoint.rb:201:in `connect'
/Users/mperham/.gem/ruby/3.0.3/gems/async-http-0.56.6/lib/async/http/client.rb:199:in `block in make_pool'
/Users/mperham/.gem/ruby/3.0.3/gems/async-pool-0.3.10/lib/async/pool/controller.rb:254:in `create_resource'
/Users/mperham/.gem/ruby/3.0.3/gems/async-pool-0.3.10/lib/async/pool/controller.rb:305:in `get_resource'
/Users/mperham/.gem/ruby/3.0.3/gems/async-pool-0.3.10/lib/async/pool/controller.rb:271:in `block in available_resource'
/Users/mperham/.gem/ruby/3.0.3/gems/async-1.30.3/lib/async/semaphore.rb:80:in `acquire'
/Users/mperham/.gem/ruby/3.0.3/gems/async-pool-0.3.10/lib/async/pool/controller.rb:270:in `available_resource'
/Users/mperham/.gem/ruby/3.0.3/gems/async-pool-0.3.10/lib/async/pool/controller.rb:236:in `wait_for_resource'
/Users/mperham/.gem/ruby/3.0.3/gems/async-pool-0.3.10/lib/async/pool/controller.rb:96:in `acquire'
/Users/mperham/.gem/ruby/3.0.3/gems/async-http-0.56.6/lib/async/http/client.rb:106:in `call'
/Users/mperham/.gem/ruby/3.0.3/gems/protocol-http-0.22.6/lib/protocol/http/middleware.rb:50:in `call'
/Users/mperham/.gem/ruby/3.0.3/gems/protocol-http-0.22.6/lib/protocol/http/accept_encoding.rb:50:in `call'
/Users/mperham/.gem/ruby/3.0.3/gems/protocol-http-0.22.6/lib/protocol/http/middleware.rb:50:in `call'
/Users/mperham/.gem/ruby/3.0.3/gems/async-rest-0.12.4/lib/async/rest/representation.rb:103:in `block (2 levels) in <class:Representation>'
/Users/mperham/.gem/ruby/3.0.3/gems/async-rest-0.12.4/lib/async/rest/representation.rb:119:in `value!'
/Users/mperham/.gem/ruby/3.0.3/gems/async-rest-0.12.4/lib/async/rest/representation.rb:134:in `value'
<internal:kernel>:90:in `tap'
/Users/mperham/.gem/ruby/3.0.3/gems/async-rest-0.12.4/lib/async/rest/resource.rb:84:in `get'
/Users/mperham/.gem/ruby/3.0.3/gems/cloudflare-4.3.0/lib/cloudflare/paginate.rb:29:in `each'
Ah, it was another block of code I had not updated. Apologies. For anyone else:
- client = Cloudflare.connect(key: CF_KEY, email: CF_EMAIL)
- zone = client.zones.find_by_name("contribsys.com")
- dns_records = zone.dns_records.all
- dns_records.each do |elm|
- puts elm
+ Cloudflare.connect(key: CF_KEY, email: CF_EMAIL) do |client|
+ zone = client.zones.find_by_name("contribsys.com")
+ zone.dns_records.each do |elm|
+ puts elm
+ end
end
Awesome!
I don't understand the migration policy for v4. If you are going to require
connect
to take a block, please break the old usage and raise an error with the fix. Instead I had to find this repo, find an associated issue and then realize that the semantics for connect had changed.Something like this would help immensely: