Skip to content

Commit

Permalink
Do not report SignalException in at_exit handler (#1267)
Browse files Browse the repository at this point in the history
The `SignalException` can be a normal signal that leads to a shutdown.
We do not need to report those normal events.

If people do want to report this error they can add their own `at_exit`
handler, but let's not report it by default.
  • Loading branch information
tombruijn authored Aug 29, 2024
1 parent e237630 commit 3ba3ce3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: fix
---

Do not report `SignalException` errors from our `at_exit` error reporter.
3 changes: 2 additions & 1 deletion lib/appsignal/hooks/at_exit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def self.call

IGNORED_ERRORS = [
# Normal exits from the application we do not need to report
SystemExit
SystemExit,
SignalException
].freeze

def self.ignored_error?(error)
Expand Down
11 changes: 11 additions & 0 deletions spec/lib/appsignal/hooks/at_exit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ def call_callback
end.to_not change { created_transactions.count }.from(1)
end
end

it "doesn't report the error if it is a SignalException exception" do
with_error(SignalException, "TERM") do |error|
Appsignal.report_error(error)
expect(created_transactions.count).to eq(1)

expect do
call_callback
end.to_not change { created_transactions.count }.from(1)
end
end
end

0 comments on commit 3ba3ce3

Please sign in to comment.