Git Product home page Git Product logo

Comments (6)

ioquatix avatar ioquatix commented on May 18, 2024 2

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.

from cloudflare.

mperham avatar mperham commented on May 18, 2024 1

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

from cloudflare.

ioquatix avatar ioquatix commented on May 18, 2024

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?

from cloudflare.

mperham avatar mperham commented on May 18, 2024

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..

from cloudflare.

mperham avatar mperham commented on May 18, 2024

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'

from cloudflare.

ioquatix avatar ioquatix commented on May 18, 2024

Awesome!

from cloudflare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.