From b81d8c947972761a8f3c8f82bb594ffd2f701b25 Mon Sep 17 00:00:00 2001 From: Mac Siri Date: Tue, 15 Mar 2022 14:05:04 -0400 Subject: [PATCH] Add Errno::EHOSTUNREACH to Podcasts's rescue list (#16884) * Add Errno::EHOSTUNREACH to Podcasts's rescue list * Add spec --- app/services/podcasts/feed.rb | 2 +- spec/services/podcasts/feed_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/services/podcasts/feed.rb b/app/services/podcasts/feed.rb index 2892d9f73..5694bacf5 100644 --- a/app/services/podcasts/feed.rb +++ b/app/services/podcasts/feed.rb @@ -26,7 +26,7 @@ module Podcasts 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) diff --git a/spec/services/podcasts/feed_spec.rb b/spec/services/podcasts/feed_spec.rb index 33012cd96..80ecaa727 100644 --- a/spec/services/podcasts/feed_spec.rb +++ b/spec/services/podcasts/feed_spec.rb @@ -35,6 +35,15 @@ RSpec.describe Podcasts::Feed, type: :service, vcr: vcr_option do 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"