sentry-ruby: Stack level to deep error after upgrading to 4.4.0
In the version 4.4.0, we added support for capturing net/http requests as span/breadcrumbs. This feature requires patching the class, which can be done in 2 different but conflicting ways: method aliasing and module prepending. Here’s a great article from bearer explaining how these 2 approaches conflict with each other.
Fortunately, the community has been adopting the prepend approach for a while now + sentry-ruby requires Ruby 2.4+. So the chance of having the issue should be low.
How we’re going to help you upgrade
With that being said, if you’re reading this issue, chances are you’re having the conflict inside your app. So here’s our plan to help you upgrade:
- We’ll see if it’s possible to align your other dependencies toward the
prependapproach. Most of the gems that patch this library should have provided an option to switch the mode toprepend. For example,rack-mini-profilerand itsprepend_net_http_patchoption. - If the above option is not viable to you, we’ll decide whether which approach to take based on your feedback:
- Provide a way to
opt-outthis patch. - Provide an option to switch modes like some other gems do.
- Provide a way to
Update
The version 4.4.1 should solve the issue.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 26
FYI: This is very much not fixed in
4.4.1. We just tried a production deploy includingv4.4.1last night and this upgrade inadvertently took our entire site down.Not sure how much it will help, but see attached log.
Still tracking.
Update:
scout_apmmentioned that they plan to switch to theprependapproach too in the upcoming5.0version:https://github.com/scoutapp/scout_apm_ruby/pull/402#issuecomment-846480983
solves the issue for me
My config:
Given that https://github.com/scoutapp/scout_apm_ruby/pull/448 has been released in version
5.3.0. I’m closing this now.If you have any similar issues, I recommend:
alias_methodprependor at least provide an option for it.alias_methodalias_method, please upgrade to a version that doesn’talias_method, but still causes this error with the SDK, please file a new issueFollowing @adi-pen’s comment:
I saw Skylight’s v5 announcement seems relevant:
Updating to Skylight v5 worked for us - required update to Ruby 2.7.3 however. (https://github.com/publiclab/mapknitter/pull/1712) (error log had been this)
@jpaulomotta There’s a glimmer of hope from Scout on this one but it’s painfully slow going for some reason: https://github.com/scoutapp/scout_apm_ruby/pull/448
So this is still very much broken despite upgrading to the latest versions of
scout_apmandsentry-*.Our latest backtrace is here. I turned on some debugging information, which might make things easier to trace.
I was finally able to reproduce the problem on a non-production instance, and – trying to debug this a bit – it looks like the execution flow is this:
The
requestmethod inNet:HTTPis defined:… and that
#requestmethod calls itssuper, which is:… that method,
Net::HTTP.request_with_scout_instruments, then callsrequest_without_scout_instruments, which is:… thereby creating the infinite loop.
I am not able to reproduce on a brand new rails app though, so I imagine the issue could just be with order in which these hooks are applied.
sentry-ruby 4.4.1is out now, which should solve the issue. Sorry for the inconvenience.