You receive the error message
SystemStackError: stack level too deep on the Error details page in your APM UI.
In addition, because of a bug in Ruby versions 2.1 and lower, you might receive only a one-line stack trace that points to the Ruby agent as the issue.
In most cases, the Ruby agent is not the underlying issue. The issue is that
Module#prepend work together only in particular situations and can cause non-terminating recursions when not used together properly.
Upgrade to Ruby version 2.2 or higher to fix the one-line stack trace bug. Then, review the full stack trace to see if the Ruby agent is the issue.
If you can't upgrade, refer to the URL included in the
SystemStackErrormessage to troubleshoot the issue or disable the Ruby agent to see if the problem disappears.
If the Ruby agent is not the cause of the error, look for evidence of non-terminating recursions including the following:
- You don't find
new_relicnear the top of the trace.
- You see repeating patterns in the trace.
- You don't find
If you see evidence of a recursion, make sure that
Module#prependare compatible with each other when used on the same method.
When your app uses
Module#prepend on a method that the Ruby agent later uses an
alias_method on, it creates a non-terminating recursion and throws the
SystemStackError: stack level too deep error.
If you upgraded to Rails 5, which deprecated
alias_method_chain, you might have replaced
Module#prepend, and that could be the source of your issue.
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.