bullet icon indicating copy to clipboard operation
bullet copied to clipboard

Callstack unhelpful with example test configuration

Open amandapouget opened this issue 7 years ago • 2 comments

Followed the bullet README to install configuration for tests. Included it in rails_helper instead of spec_helper per comments on an issue.

Stacktrace on failure is unhelpful... How to get a longer stack trace? Right now, we get:

     Failure/Error: Bullet.perform_out_of_channel_notifications if Bullet.notification?

     Bullet::Notification::UnoptimizedQueryError:
       user: amandasimon

       AVOID eager loading detected
         LoggedTime => [:project, :person]
         Remove from your finder: :includes => [:project, :person]
       Call stack
         /Users/amandasimon/Desktop/RoleModel/Almanac/spec/rails_helper.rb:26:in `block (2 levels) in <top (required)>'
     # ./spec/rails_helper.rb:26:in `block (2 levels) in <top (required)>'

So all the stack traces are rails_helper:26 and we only get that one line of trace... How can we get more?

Thanks!

amandapouget avatar May 29 '17 16:05 amandapouget

Has anyone found any workarounds for this? This makes it very difficult to add Bullet into an existing test suite.

rubendinho avatar Mar 09 '20 03:03 rubendinho

I was running into a similar same thing, and this was a workaround that worked for me:

module Bullet
  module StackTraceFilter
    # the original method here filters out any items in the stacktrace which aren't from our
    # project, but the trouble is that this can be a bit restrictive, and doesn't allow exceptions
    # for destroy callbacks, for instance.
    def caller_in_project
      select_caller_locations { true }
    end
  end
end

It just patches the stack trace filtering so that none of the items are filtered out (though you could also define some custom logic in the block to fit your use case better - the block can take a param which is the stack trace entry)

If there is interest then I might consider putting together a PR which allows the block to be configurable eg.

Bullet.stack_trace_filter = ->(location) { ... }

johansenja avatar May 13 '21 22:05 johansenja