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

Fix failing Async::HTTP specs due to Async API change #1040

Merged
merged 1 commit into from
Feb 4, 2024

Conversation

mattbrictson
Copy link
Contributor

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.

Fixes #1036

Footnotes

  1. https://github.com/socketry/async/pull/270

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
Comment on lines 364 to +366
end.wait

result.is_a?(Exception) ? raise(result) : result
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗒️ Before async 2.6.4, wait would raise an exception if the task returned an exception object (in this case, Async::TimeoutError). Since 2.6.4, wait no longer raises the exception, it just returns it as an exception object.

The webmock specs rely on the exception being raised, so I added this ternary line to restore the old wait behavior.

@mattbrictson
Copy link
Contributor Author

Looks like this PR is restoring Ruby 3.1 and 3.2 to green status in CI. 🎉

As a separate issue, Ruby head is failing due to the cookiejar gem (which is no longer being maintained) not supporting Ruby 3.3. It is a dependency of em-http-request and there is already an open issue for it: igrigorik/em-http-request#354.

@bblimke
Copy link
Owner

bblimke commented Feb 4, 2024

@mattbrictson big thanks for the thorough investigation and the fix! 🙏

@bblimke bblimke merged commit fc13468 into bblimke:master Feb 4, 2024
6 of 7 checks passed
@mattbrictson mattbrictson deleted the fix-async-specs branch February 5, 2024 00:06
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

Successfully merging this pull request may close these issues.

CI consistently failing on Ruby >= 3.1, is it ok to update?
2 participants