Skip to content

Commit

Permalink
Add Errno::EHOSTUNREACH to Podcasts's rescue list (forem#16884)
Browse files Browse the repository at this point in the history
* Add Errno::EHOSTUNREACH to Podcasts's rescue list

* Add spec
  • Loading branch information
maestromac authored Mar 15, 2022
1 parent dc903f8 commit b81d8c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/podcasts/feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_episodes(limit: 100, force_update: false)
end
podcast.update_columns(reachable: true, status_notice: "")
feed.items.size
rescue Net::OpenTimeout, Errno::ECONNREFUSED, SocketError, HTTParty::RedirectionTooDeep
rescue Net::OpenTimeout, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError, HTTParty::RedirectionTooDeep
set_unreachable(status: :unreachable, force_update: force_update)
rescue OpenSSL::SSL::SSLError
set_unreachable(status: :ssl_failed, force_update: force_update)
Expand Down
9 changes: 9 additions & 0 deletions spec/services/podcasts/feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
expect(unpodcast.status_notice).to include("is not reachable")
end

it "sets reachable when hitting ip issue" do
allow(HTTParty).to receive(:get).with("http://podcast.example.com/podcast", httparty_options).and_raise(
Errno::EHOSTUNREACH,
)
described_class.new(unpodcast).get_episodes(limit: 2)
unpodcast.reload
expect(unpodcast.reachable).to be false
end

it "sets reachable when there redirection is too deep" do
allow(HTTParty).to receive(:get).with("http://podcast.example.com/podcast", httparty_options).and_raise(
HTTParty::RedirectionTooDeep, "too deep"
Expand Down

0 comments on commit b81d8c9

Please sign in to comment.