From 3562c598ef5b44a5b6d7921294a443654688c26c Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Tue, 21 Jun 2022 09:23:36 +0800 Subject: [PATCH] DEV: Upgrade Sidekiq to 6.5 (#17142) --- Gemfile.lock | 4 ++-- lib/discourse.rb | 7 +------ lib/sidekiq_logster_reporter.rb | 2 +- spec/lib/discourse_spec.rb | 8 ++++++-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8a45e1ef53d..1d94f3797c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -450,7 +450,7 @@ GEM activesupport (>= 3.1) shoulda-matchers (5.1.0) activesupport (>= 5.2.0) - sidekiq (6.4.2) + sidekiq (6.5.1) connection_pool (>= 2.2.2) rack (~> 2.0) redis (>= 4.2.0) @@ -637,4 +637,4 @@ DEPENDENCIES yaml-lint BUNDLED WITH - 2.3.13 + 2.3.16 diff --git a/lib/discourse.rb b/lib/discourse.rb index dc0a93447ee..757eeabf325 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -9,11 +9,6 @@ module Discourse DB_POST_MIGRATE_PATH ||= "db/post_migrate" REQUESTED_HOSTNAME ||= "REQUESTED_HOSTNAME" - require 'sidekiq/exception_handler' - class SidekiqExceptionHandler - extend Sidekiq::ExceptionHandler - end - class Utils URI_REGEXP ||= URI.regexp(%w{http https}) @@ -168,7 +163,7 @@ module Discourse return if ex.class == Jobs::HandledExceptionWrapper context ||= {} - parent_logger ||= SidekiqExceptionHandler + parent_logger ||= Sidekiq cm = RailsMultisite::ConnectionManagement parent_logger.handle_exception(ex, { diff --git a/lib/sidekiq_logster_reporter.rb b/lib/sidekiq_logster_reporter.rb index 30208ccb59d..51fe14d21ac 100644 --- a/lib/sidekiq_logster_reporter.rb +++ b/lib/sidekiq_logster_reporter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class SidekiqLogsterReporter < Sidekiq::ExceptionHandler::Logger +class SidekiqLogsterReporter def call(ex, context = {}) return if Jobs::HandledExceptionWrapper === ex diff --git a/spec/lib/discourse_spec.rb b/spec/lib/discourse_spec.rb index b41d11dd2c7..b419814331c 100644 --- a/spec/lib/discourse_spec.rb +++ b/spec/lib/discourse_spec.rb @@ -321,8 +321,9 @@ describe Discourse do context "#handle_exception" do - class TempSidekiqLogger < Sidekiq::ExceptionHandler::Logger + class TempSidekiqLogger attr_accessor :exception, :context + def call(ex, ctx) self.exception = ex self.context = ctx @@ -332,10 +333,13 @@ describe Discourse do let!(:logger) { TempSidekiqLogger.new } before do - Sidekiq.error_handlers.clear Sidekiq.error_handlers << logger end + after do + Sidekiq.error_handlers.delete(logger) + end + it "should not fail when called" do exception = StandardError.new