socketry / cloudflare

An asynchronous Ruby wrapper for the CloudFlare V4 API.
MIT License
139 stars 88 forks source link

Fix support for Workers KV #70

Closed idletea closed 3 years ago

idletea commented 3 years ago

Description

Fixes https://github.com/socketry/cloudflare/issues/63

Makes the Workers KV tests pass by handling both binary and JSON payloads. Handling both requires a new Async::REST::Wrapper which dispatches to different parsers based on the content-type of the response.

Doing this is predicated on this upstream PR to async-rest, though: https://github.com/socketry/async-rest/pull/7 (hence a version bump in the dependencies to a currently non-existent version of async-rest)

ioquatix commented 3 years ago

Upstream bug fix is now merged and released.

ioquatix commented 3 years ago

Thanks for your contribution and sorry for the delayed response. I'll release an update shortly.

ioquatix commented 3 years ago

Okay released in v4.3.0

However, I noticed one test failure:

  1) Cloudflare::KV::Namespaces can delete keys
     Failure/Error:
       expect do
        account.kv_namespaces.find_by_id(namespace.id).read_value(key)
       end.to raise_error(Cloudflare::RequestError)

       expected Cloudflare::RequestError but nothing was raised
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-support-3.10.2/lib/rspec/support.rb:102:in `block in <module:Support>'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-support-3.10.2/lib/rspec/support.rb:111:in `notify_failure'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-expectations-3.10.1/lib/rspec/expectations/fail_with.rb:35:in `fail_with'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-expectations-3.10.1/lib/rspec/expectations/handler.rb:40:in `handle_failure'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-expectations-3.10.1/lib/rspec/expectations/handler.rb:56:in `block in handle_matcher'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-expectations-3.10.1/lib/rspec/expectations/handler.rb:27:in `with_matcher'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-expectations-3.10.1/lib/rspec/expectations/handler.rb:48:in `handle_matcher'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-expectations-3.10.1/lib/rspec/expectations/expectation_target.rb:65:in `to'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-expectations-3.10.1/lib/rspec/expectations/expectation_target.rb:101:in `to'
     # ./spec/cloudflare/kv/namespaces_spec.rb:53:in `block (2 levels) in <top (required)>'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:262:in `instance_exec'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:262:in `block in run'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:508:in `block in with_around_and_singleton_context_hooks'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:465:in `block in with_around_example_hooks'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:486:in `block in run'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-core-3.10.1/lib/rspec/core/hooks.rb:626:in `block in run_around_example_hooks_for'
     # /home/samuel/.gem/ruby/2.7.3/gems/rspec-core-3.10.1/lib/rspec/core/example.rb:350:in `call'
     # /home/samuel/.gem/ruby/2.7.3/gems/async-rspec-1.16.0/lib/async/rspec/reactor.rb:89:in `block (3 levels) in <module:RSpec>'
     # /home/samuel/.gem/ruby/2.7.3/gems/async-rspec-1.16.0/lib/async/rspec/reactor.rb:59:in `block (2 levels) in run_in_reactor'
     # /home/samuel/.gem/ruby/2.7.3/gems/async-1.29.0/lib/async/task.rb:263:in `block in make_fiber'

This seems relatively low priority but if you have any idea what is going on, PRs welcome.

ioquatix commented 3 years ago

Maybe race condition in CI?

https://github.com/socketry/cloudflare/runs/2824122007?check_suite_focus=true#step:4:148