mirror of https://github.com/rails/rails
ActiveSupport::Reloader should not report exception
Since it always delegate to an actual executor that does report them already, this cause exceptions to be reported twice. Fix: https://github.com/rails/rails/issues/46100
This commit is contained in:
parent
2d36ebc729
commit
c6886a1ab0
|
@ -91,7 +91,7 @@ module ActiveSupport
|
|||
begin
|
||||
yield
|
||||
rescue => error
|
||||
error_reporter.report(error, handled: false, source: source)
|
||||
error_reporter&.report(error, handled: false, source: source)
|
||||
raise
|
||||
ensure
|
||||
instance.complete!
|
||||
|
@ -108,7 +108,7 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
def self.error_reporter
|
||||
def self.error_reporter # :nodoc:
|
||||
ActiveSupport.error_reporter
|
||||
end
|
||||
|
||||
|
|
|
@ -68,8 +68,15 @@ module ActiveSupport
|
|||
|
||||
# Run the supplied block as a work unit, reloading code as needed
|
||||
def self.wrap(**kwargs)
|
||||
return yield if active?
|
||||
|
||||
executor.wrap(**kwargs) do
|
||||
super
|
||||
instance = run!
|
||||
begin
|
||||
yield
|
||||
ensure
|
||||
instance.complete!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -85,6 +85,17 @@ class ReloaderTest < ActiveSupport::TestCase
|
|||
assert_equal [:before_unload, :unload, :after_unload, :body], called
|
||||
end
|
||||
|
||||
def test_report_errors_once
|
||||
reports = ErrorCollector.record do
|
||||
assert_raises RuntimeError do
|
||||
reloader.wrap do
|
||||
raise "Oops"
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_equal 1, reports.size
|
||||
end
|
||||
|
||||
private
|
||||
def new_reloader(&check)
|
||||
Class.new(ActiveSupport::Reloader).tap do |r|
|
||||
|
|
Loading…
Reference in New Issue