finite_machine
finite_machine copied to clipboard
Change how the callback queue is cleared from the finalizer.
Describe the change
Fixes the "undefined local variable or method `callback_queue' for FiniteMachine::Observer:Class (NameError)" exception thrown in Ruby 3.1.1
Why are we doing this?
In Ruby 3.1.1, accessing callback_queue from a finalizer causes a "undefined local variable or method `callback_queue' for FiniteMachine::Observer:Class (NameError)", and callback_queue is never cleaned up. However, making the finalizer an instance method rather than a class method throws a warning about improper use of finalizers.
The fix is borrowed from a Github issue found at https://github.com/appsignal/rdkafka-ruby/pull/160/files.
Benefits
This library will become compatible with Ruby 3.1.1.
Drawbacks
None.
Requirements
- [X] Tests passing locally?
- [X] Code style checked?
- [X] Rebased with
masterbranch? - [ ] Documentation updated?
- [ ] Changelog updated?
This just hit me also when trying to update an application to ruby 3.1.
What do we need to be able to merge this?
Hello :wave: - Re-asking @dup2 question: what do we need to be able to merge this?
@piotrmurach Please let me know if there's anything else you need me to do to get this merged. Thanks.
I've made a bit of refactoring to address your comments and after familiarizing myself further with how the ObjectSpace class works. Hopefully, this can be merged now, but I'm happy to hear any other feedback.
@piotrmurach Is there anything we can do to get this merged and make this lib compatible with Ruby 3.1+. Happy to help in any way possible
@piotrmurach Is there anything we can do to get this merged and make this lib compatible with Ruby 3.1+. Happy to help in any way possible
@abhishekjain16 You could help resolve the failing pipelines. That's probably the only thing that is still needed.
@vkononov https://github.com/piotrmurach/finite_machine/pull/74/files#r1285879315 This should fix the pipeline
Thank you, @abhishekjain16. Can't believe I missed that. @piotrmurach, Could you run the pipeline and merge this code if the pipeline succeeds?
Thanks for this. Are there any imminent plans to release a new version to RubyGems with this fix?
@jimbali Thanks for your interest. I'm preparing a new release but cannot promise any timelines.
Hi @piotrmurach, have you found any time to prepare a release for this yet? Any idea when that might be? Thanks
Hi @jimbali, I appreciate your patience. I had to deal with upsetting news from my family that didn't allow me the headspace to finish what I wanted. I released a new 0.14.1 version with a few fixes. Please see the changelog for more information.
Aw man, really sorry to hear that. Thanks for finding the time to sort this out. I've sponsored you a couple of coffees!
@jimbali That's life and the show must go on. You didn't have to but thank you. Appreciate your kindness. 🙏