-
Notifications
You must be signed in to change notification settings - Fork 174
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
Rake integration gets into an infinite loop if anything else overrides execute
#556
Comments
Hi @DanielHeath After trying a few things, it looks like adding a |
That lets me have both gems in the project, but once you actually use honeycomb the problem is back.
I would prefer to have both error and timing instrumentation on my scheduled rake tasks, if possible.
Thanks,
Daniel Heath
… On 8 Aug 2019, at 5:18 am, Toby Hsieh ***@***.***> wrote:
Hi @DanielHeath
After trying a few things, it looks like adding a require: false in the Gemfile (like gem 'honeycomb-beeline', '1.0.0', require: false) avoids the issue. Would this be an acceptable workaround for now?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
One (ugly but well supported) option is to set a thread variable on entry and check it before recursion.
Thanks,
Daniel Heath
… On 8 Aug 2019, at 5:18 am, Toby Hsieh ***@***.***> wrote:
Hi @DanielHeath
After trying a few things, it looks like adding a require: false in the Gemfile (like gem 'honeycomb-beeline', '1.0.0', require: false) avoids the issue. Would this be an acceptable workaround for now?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I made an update to my original comment that may have been missed (about requiring 'honeycomb-beeline' in an initializer file). I have the following, and it doesn't encounter an infinite loop/recursion:
|
Gave that a try, but there's a lot of situations in my app where a rake task is invoked after the environment has already been loaded, which still hits this error. |
This might fix #556 If another gem uses `Module#prepend` on `Rake::Task`, then it can lead to infinite mutual recursion if we use alias_method to monkey patch the `#execute` method.
This might fix #556 If another gem uses `Module#prepend` on `Rake::Task`, then it can lead to infinite mutual recursion if we use alias_method to monkey patch the `#execute` method.
This might fix #556 If another gem uses `Module#prepend` on `Rake::Task`, then it can lead to infinite mutual recursion if we use alias_method to monkey patch the `#execute` method.
Can you give the branch at https://github.com/bugsnag/bugsnag-ruby/tree/tobyhs/rake_with_module_prepend a try to see if it works for your app? |
Tried switching to that branch, and the mutual recursion is gone :) thanks. |
This might fix #556 If another gem uses `Module#prepend` on `Rake::Task`, then it can lead to infinite mutual recursion if we use alias_method to monkey patch the `#execute` method.
It looks like the code introduced to fix this actually ends up breaking compatibility with other gems, such as elastic/apm-agent-ruby. This blog post from New Relic explains the incompatibility in some detail. In our application, we tried to get bugsnag to load after the elastic-apm gem, but we weren't able to get it working, and our workaround for now was to use a version of the bugsnag gem earlier than v6.12.0. There's also some discussion on this issue on the elastic-apm gem's tracker. I'm not sure what the best solution is here, as this seems to be a language issue that has brought about these incompatibilities in libraries that implement things differently. |
Hey @danarnold, thanks for bringing this to our attention. Much like the discussions in apm-agent-ruby, we're having the similar ones here. There's going to be some incompatibilities depending on what libraries the user is using in their project, and whether they have interfering methods. For the benefit of future readers; the Ruby gems prior to |
Description
I'm using https://github.com/honeycombio/beeline-ruby alongside bugsnag-ruby. They aren't getting along, though. The overrides of
Rake::Task#execute
are mutually recursing.Having had a read of the relevant code on both sides (honeycomb and bugsnag), I think the issue is on the bugsnag-ruby side.
Stack trace
The issue is that honeycomb defines
execute
in a module, which it adds usingprepend
. It callssuper
, which (thanks to aliasing) isexecute_with_bugsnag
, which callsexecute_without_bugsnag
, which (also thanks to the aliasing in bugsnag-ruby) is theexecute
implementation defined by honeycomb.This is complex, because bugsnag supports ruby < 2, which doesn't have
prepend
. Otherwise it'd an easy fix (do it the ruby 2 way with prepend).I think changing to use a module for the extra behavior added to
Rake::Task
would solve this immediate issue, but not being able to useprepend
means you wouldn't be instrumenting other modules mixed intoRake::Task
.The text was updated successfully, but these errors were encountered: