-
-
Notifications
You must be signed in to change notification settings - Fork 513
Fix: Handle exception with large stacktrace without dropping entire item - by keeping N frames #1807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Handle exception with large stacktrace without dropping entire item - by keeping N frames #1807
Conversation
|
||
result = item.to_s | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in #1806 (comment), we should update the log message as well (see line 106).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should it be updated to since this PR remove some frames only (or keeping some frames)
Is |
18bf1f4
to
65b1ff1
Compare
In case a new config option is desired |
Please let me know early if you got any comment |
@PikachuEXE It's mainly because I don't work on this full-time 🙂 |
@sl0thentr0py Do you think this will fit into enhancement or bug fix? I think it's kinda an enhancement but you can also argue that we should've handled the oversized frames. |
@st0012 I'd say improvements to truncation count as enhancement |
OK no problem |
@PikachuEXE I think 10 is way too conservative, taking an average stacktrace line like
the length is approximately 100 bytes, so even with an upper bound of 200 bytes, we can fit 1024 such lines into I'd therefore pick something like 100 or even 500 for truncating the number of frames. |
6651220
to
4e48130
Compare
Here is my script for reproducing a require "sentry-ruby"
# thingy.rb
class Thingy
def thingy
puts "thingy"
end
end
# thingy_with_foo.rb
module ThingyWithFoo
def thingy
# puts "thingy with foo"
super
end
end
Thingy.prepend(ThingyWithFoo)
# thingy_with_bar.rb
class Thingy
alias_method :thingy_without_bar, :thingy # Wont't alias create an alias for Thingy#thingy but ThingyWithFoo#thingy instead
def thingy_with_bar
# puts "thingy with bar"
thingy_without_bar # Expected to call original Thingy#thingy method but will call prepended method instead
end
alias_method :thingy, :thingy_with_bar
end
::Sentry.init do |config|
config.dsn = ""
config.debug = true
# config.logger = Logger.new(STDOUT, level: :debug)
end
begin
Thingy.new.thingy # raises: stack level too deep (SystemStackError))
rescue SystemStackError => exception
Sentry.capture_exception(exception)
# puts exception.backtrace.size #=> 11911
# puts exception.backtrace[-100..-1]
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx @PikachuEXE, also cool observation with taking N/2 frames on both sides!
lgtm now
Let me cut a patch release for #1812 first then I'll start merging feature PRs |
Please let me know when you area ready to merge this |
Certain exception type such as `SystemStackError` has long backtrace (thus the stack error) The whole envelope item was dropped due to payload size limit logic This ensures it tries to remove most of the stacktrace frames (except first 10) when payload is too large, so that the envelope item won't be dropped = exception still reported
4e48130
to
f897b45
Compare
Resolved conflict on |
Thank you. I’ll give it another pass this week 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great work 👍
Description
This should fix #1799
Certain exception type such as
SystemStackError
has long backtrace (thus the stack error)The whole envelope item was dropped due to payload size limit logic
This ensures it tries to remove most of the stacktrace frames (except first 10) when payload is too large, so that the envelope item won't be dropped = exception still reported
This is an alternative to #1806
Note:
10
is a random number I picked so feel free to suggest other numbers