Giter VIP home page Giter VIP logo

Comments (9)

joshuap avatar joshuap commented on June 23, 2024 1

@sshaw @subzero10 I think the issue is that minitest/autorun is using an at_exit to run the tests, which is running after our own at_exit cleans up (calls Honeybadger.stop) and shuts down our agent.

If you require Honeybadger in plain Ruby mode (which skips our at_exit), the tests pass:

require "minitest/autorun"
- require "honeybadger"
+ require "honeybadger/ruby"

# ...

I also added the following config to get a bit more logging:

Honeybadger.configure do |config|
  config.backend = :test
  config.api_key = "whatEVER!"
+  config.logger = Logger.new($stdout)
+  config.debug = true
end

from honeybadger-ruby.

sshaw avatar sshaw commented on June 23, 2024 1

Thanks. That works in the above example but in the real case the code being tested does a require "honeybadger" which will negate the require "honeybadger/ruby". Here's the logging output:

** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=5.2.1 framework=ruby level=1 pid=55372
I, [2023-08-03T19:52:01.900005 #55372]  INFO -- honeybadger: shutting down worker level=0 pid=55372 at="lib/honeybadger/worker.rb:53:in `shutdown'"
I, [2023-08-03T19:52:01.900121 #55372]  INFO -- honeybadger: killing worker thread level=0 pid=55372 at="lib/honeybadger/worker.rb:128:in `kill!'"
Run options: --seed 33418

# Running:

I, [2023-08-03T19:52:05.251854 #55372]  INFO -- honeybadger: Reporting error id=XXXXX-9259-XXXXX-95e0-842ebf55be85 level=1 pid=55372
I, [2023-08-03T19:52:07.256001 #55372]  INFO -- honeybadger: Reporting error id=XXXXX-0fa5-XXXXX-9b45-24e18581e746 level=1 pid=55372
F

Failure:
TestMeme#test_bar [test.rb:31]:
Expected: 2
  Actual: 0


rails test test.rb:23

I, [2023-08-03T19:52:07.258525 #55372]  INFO -- honeybadger: Reporting error id=XXXXX-a379-XXXXX-bab5-6ad95085f473 level=1 pid=55372
F

Failure:
TestMeme#test_foo [test.rb:20]:
Expected: 1
  Actual: 0


rails test test.rb:17



Finished in 2.010293s, 0.9949 runs/s, 0.9949 assertions/s.
2 runs, 2 assertions, 2 failures, 0 errors, 0 skips

from honeybadger-ruby.

sshaw avatar sshaw commented on June 23, 2024 1

rails test test.rb:17

Odd that this shows but after a fresh bundle install it goes away and I get the same error

from honeybadger-ruby.

sshaw avatar sshaw commented on June 23, 2024 1

Here's something that might work. Add the following to your honeybadger.yml config:

This did not work when the config file was in the project's root directory.

or use the HONEYBADGER_SEND_DATA_AT_EXIT=false environment variable when running tests.

This fixed things. Thanks!

Would def add some docs on how to deal with this! 📝

from honeybadger-ruby.

sshaw avatar sshaw commented on June 23, 2024 1

or use the HONEYBADGER_SEND_DATA_AT_EXIT=false environment variable when running tests.

This fixed things. Thanks!

For future readers: this worked as an env var but not via Honeybadger.configure { |cfg| cfg.send_data_at_exit = false }

from honeybadger-ruby.

joshuap avatar joshuap commented on June 23, 2024 1

Here's something that might work. Add the following to your honeybadger.yml config:

This did not work when the config file was in the project's root directory.

or use the HONEYBADGER_SEND_DATA_AT_EXIT=false environment variable when running tests.

This fixed things. Thanks!

Would def add some docs on how to deal with this! 📝

@subzero10 should we document this somewhere, maybe in the troubleshooting guide?

from honeybadger-ruby.

subzero10 avatar subzero10 commented on June 23, 2024 1

@subzero10 should we document this somewhere, maybe in the troubleshooting guide?

Yes, I'll take care of that :)

from honeybadger-ruby.

sshaw avatar sshaw commented on June 23, 2024

More info:

~/code/ruby/honeybadger-test >cat Gemfile
source "https://rubygems.org"
gem "honeybadger"
gem "minitest"
~/code/ruby/honeybadger-test >cat Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    honeybadger (5.2.1)
    minitest (5.19.0)

PLATFORMS
  ruby

DEPENDENCIES
  honeybadger
  minitest

BUNDLED WITH
   2.1.0

~/code/ruby/honeybadger-test >bundle exec ruby test.rb
** [Honeybadger] Initializing Honeybadger Error Tracker for Ruby. Ship it! version=5.2.1 framework=ruby level=1 pid=10575
Run options: --seed 30909

# Running:

** [Honeybadger] Reporting error id=XXXXX level=1 pid=10575
** [Honeybadger] Reporting error id=XXXXX level=1 pid=10575
F** [Honeybadger] Reporting error id=XXXXX level=1 pid=10575
F

Finished in 2.005228s, 0.9974 runs/s, 0.9974 assertions/s.

  1) Failure:
TestMeme#test_bar [test.rb:28]:
Expected: 2
  Actual: 0

  2) Failure:
TestMeme#test_foo [test.rb:17]:
Expected: 1
  Actual: 0

2 runs, 2 assertions, 2 failures, 0 errors, 0 skips

from honeybadger-ruby.

joshuap avatar joshuap commented on June 23, 2024

Here's something that might work. Add the following to your honeybadger.yml config:

test:
  send_data_at_exit: false

or use the HONEYBADGER_SEND_DATA_AT_EXIT=false environment variable when running tests.

That should skip the Honeybadger.stop call in our at_exit callback:

def install_at_exit_callback
at_exit do
if $! && !ignored_exception?($!) && Honeybadger.config[:'exceptions.notify_at_exit']
Honeybadger.notify($!, component: 'at_exit', sync: true)
end
Honeybadger.stop if Honeybadger.config[:'send_data_at_exit']
end
end

from honeybadger-ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.