ruby / error_highlight

The gem enhances Exception#message by adding a short explanation where the exception is raised
MIT License
150 stars 23 forks source link

Doesn't work well when GC.stress is true with prism #47

Closed luke-gru closed 1 month ago

luke-gru commented 1 month ago

Run with --parser=prism or with ruby master:

GC.stress = true
A::B = [1,2,3,4] # should show error, but hangs

This hangs, because error_highlight calls require "prism", which requires and parses a huge amount of code. I think in this case, error_highlight should turn GC.stress off. Something like:

def self.spot(obj, **opts)
  old_stress = GC.stress
  ...
ensure
  GC.stress = old_stress
end
mame commented 1 month ago

I think it is a bad idea to do such a thing on the library side. The person using GC.stress = true should deal with the hassle. In this case, just requiring “prism” before calling GC.stress = true would be sufficient.