Dont let HTTParty::RedirectionTooDeep Errors kill Podcast Ep. Update Workers (#6735) [deploy]

Co-authored-by: lightalloy <lightallloy@gmail.com
This commit is contained in:
Molly Struve 2020-03-20 08:19:14 -05:00 committed by GitHub
parent 68dedc8a47
commit c3b88d19de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -20,11 +20,11 @@ module Podcasts
end
podcast.update_columns(reachable: true, status_notice: "")
feed.items.size
rescue Net::OpenTimeout, Errno::ECONNREFUSED, SocketError => _e
rescue Net::OpenTimeout, Errno::ECONNREFUSED, SocketError, HTTParty::RedirectionTooDeep
set_unreachable(:unreachable, force_update)
rescue OpenSSL::SSL::SSLError => _e
rescue OpenSSL::SSL::SSLError
set_unreachable(:ssl_failed, force_update)
rescue RSS::NotWellFormedError => _e
rescue RSS::NotWellFormedError
set_unreachable(:unparsable, force_update)
end

View file

@ -34,6 +34,13 @@ RSpec.describe Podcasts::Feed, type: :service, vcr: vcr_option do
expect(unpodcast.status_notice).to include("is not reachable")
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")
described_class.new(unpodcast).get_episodes(limit: 2)
unpodcast.reload
expect(unpodcast.reachable).to be false
end
it "schedules the update url jobs when setting as unreachable" do
allow(HTTParty).to receive(:get).with("http://podcast.example.com/podcast", httparty_options).and_raise(Errno::ECONNREFUSED)
create_list(:podcast_episode, 2, podcast: unpodcast)