Skip to content

Commit 35f364b

Browse files
committed
Correctly return Job#perform's return value (#1667)
1 parent ed12bab commit 35f364b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

sentry-rails/lib/sentry/rails/active_job.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ def capture_and_reraise_with_sentry(scope, &block)
2424

2525
scope.set_span(transaction) if transaction
2626

27-
block.call
27+
return_value = block.call
2828

2929
finish_sentry_transaction(transaction, 200)
30+
31+
return_value
3032
rescue Exception => e # rubocop:disable Lint/RescueException
3133
finish_sentry_transaction(transaction, 500)
3234

sentry-rails/spec/sentry/rails/activejob_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
require "spec_helper"
22
require "active_job/railtie"
33

4+
class NormalJob < ActiveJob::Base
5+
def perform
6+
"foo"
7+
end
8+
end
9+
410
class FailedJob < ActiveJob::Base
511
self.logger = nil
612

@@ -47,6 +53,10 @@ def rescue_callback(error)
4753
it "runs job" do
4854
expect { FailedJob.perform_now }.to raise_error(FailedJob::TestError)
4955
end
56+
57+
it "returns #perform method's return value" do
58+
expect(NormalJob.perform_now).to eq("foo")
59+
end
5060
end
5161

5262
RSpec.describe "ActiveJob integration" do
@@ -62,6 +72,10 @@ def rescue_callback(error)
6272
Sentry.get_current_client.transport
6373
end
6474

75+
it "returns #perform method's return value" do
76+
expect(NormalJob.perform_now).to eq("foo")
77+
end
78+
6579
it "adds useful context to extra" do
6680
expect { FailedJob.perform_now }.to raise_error(FailedJob::TestError)
6781

0 commit comments

Comments
 (0)