Skip to content

Commit

Permalink
Fix failing Async::HTTP specs due to Async API change
Browse files Browse the repository at this point in the history
The `async` gem recently made a breaking API change that was released in
patch version 2.6.4.[^1] Following the change, async tasks that return
an  exception object will no longer raise that exception when `wait` is
called.

The `Async::HTTP` specs in webmock were written to leverage the old
behavior of `wait`. Since async 2.6.4 was released, these specs have
been failing in CI.

This commit fixes the failing specs by updating how `wait` is used, such
that exceptions are still raised as expected in async 2.6.4. This should
restore CI to a working state.

[^1]: socketry/async#270
  • Loading branch information
mattbrictson committed Oct 24, 2023
1 parent 63940ac commit ee03e77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion spec/acceptance/async_http_client/async_http_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
end

def make_request(method, url, protocol: nil, headers: {}, body: nil)
Async do
result = Async do
endpoint = Async::HTTP::Endpoint.parse(url)

begin
Expand All @@ -362,6 +362,8 @@ def make_request(method, url, protocol: nil, headers: {}, body: nil)
e
end
end.wait

result.is_a?(Exception) ? raise(result) : result
end

def response_to_hash(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def http_request(method, url, options = {}, &block)

body = options[:body]

Async do
result = Async do
begin
Async::HTTP::Client.open(endpoint) do |client|
response = client.send(
Expand All @@ -34,6 +34,8 @@ def http_request(method, url, options = {}, &block)
e
end
end.wait

result.is_a?(Exception) ? raise(result) : result
end

def client_timeout_exception_class
Expand Down

0 comments on commit ee03e77

Please sign in to comment.