Skip to content

Conversation

@matthee
Copy link

@matthee matthee commented Oct 2, 2025

Adds the Errno::EHOSTUNREACH to the retry conditions when trying to connect to a host endpoint. I'm not sure, under which conditions this specific errno is thrown, however I've experienced it when playing around with the async-dns wikipedia example.

Fixes #18.

Types of Changes

  • Bug fix.

Contribution

@jaredcwhite
Copy link

@matthee FYI, when I tried this out it said it needed to be Errno:EHOSTUNREACH (the E at the start of the const).

@matthee
Copy link
Author

matthee commented Oct 22, 2025

Well, this is embarrassing 😅
@jaredcwhite You are absolutely right! Fixed it - thanks for catching this bug!

I ran the tests locally and everything seemed to be fine. I discovered that the connect method is covererd by the test suite. However, there seem to be no tests for the retry logic. @ioquatix I'm not sure on how to best implement these - could you give me a hint?

@matthee matthee changed the title Add HOSTUNREACH to retry conditions Add EHOSTUNREACH to retry conditions Oct 22, 2025
@ioquatix
Copy link
Member

You could provide a custom wrapper and write:

expect(wrapper).to receive(:connect).and_raise(Errno::EHOSTUNREACH)

https://github.com/socketry/sus/blob/08a13e433dc4f234b3dc65e0a25c770516634070/context/mocking.md?plain=1#L48-L56

Hope that helps.

@matthee
Copy link
Author

matthee commented Dec 19, 2025

I completely forgot about this PR - i will have a go during the upcoming holiday season.

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.

Add Errno::EHOSTUNREACH to rescue clause in HostEndpoint#connect

3 participants