bugsnag / bugsnag-ruby

BugSnag error monitoring & reporting software for rails, sinatra, rack and ruby
https://docs.bugsnag.com/platforms/ruby
MIT License
248 stars 173 forks source link

Prevent possible infinite loop in rake spec #733

Closed imjoehaines closed 1 year ago

imjoehaines commented 1 year ago

Goal

One of our Rake specs runs a command and expects it to report to Bugsnag. If this doesn't work for whatever reason, it gets stuck in an infinite loop. This is because Queue#pop blocks until there is something on the queue to pop, but if the command didn't work as expected there will never be anything added to the queue

We can't simply detect if the command worked or not as it's designed to crash (so will always have a failing exit code) and even if we ensured the output matched what we expect, it's still possible for this code to cause an infinite loop

I've changed the spec to use the non-blocking form of Queue#pop and make multiple attempts before failing, which will prevent it from looping infinitely

imjoehaines commented 1 year ago

Maybe it makes sense to replace or remove let(:request) (line 55)?

Yeah, definitely!