finite_machine icon indicating copy to clipboard operation
finite_machine copied to clipboard

Change how the callback queue is cleared from the finalizer.

Open vkononov opened this issue 3 years ago • 1 comments

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 master branch?
  • [ ] Documentation updated?
  • [ ] Changelog updated?

vkononov avatar Mar 15 '22 06:03 vkononov

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?

dup2 avatar Jul 01 '22 21:07 dup2

Hello :wave: - Re-asking @dup2 question: what do we need to be able to merge this?

luiswitz avatar May 05 '23 19:05 luiswitz

@piotrmurach Please let me know if there's anything else you need me to do to get this merged. Thanks.

vkononov avatar May 25 '23 15:05 vkononov

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.

vkononov avatar Jul 06 '23 05:07 vkononov

@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 avatar Aug 03 '23 20:08 abhishekjain16

@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 avatar Aug 04 '23 04:08 vkononov

@vkononov https://github.com/piotrmurach/finite_machine/pull/74/files#r1285879315 This should fix the pipeline

abhishekjain16 avatar Aug 07 '23 13:08 abhishekjain16

Thank you, @abhishekjain16. Can't believe I missed that. @piotrmurach, Could you run the pipeline and merge this code if the pipeline succeeds?

vkononov avatar Aug 08 '23 18:08 vkononov

Thanks for this. Are there any imminent plans to release a new version to RubyGems with this fix?

jimbali avatar Aug 30 '23 15:08 jimbali

@jimbali Thanks for your interest. I'm preparing a new release but cannot promise any timelines.

piotrmurach avatar Aug 30 '23 21:08 piotrmurach

Hi @piotrmurach, have you found any time to prepare a release for this yet? Any idea when that might be? Thanks

jimbali avatar Sep 28 '23 12:09 jimbali

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.

piotrmurach avatar Oct 08 '23 18:10 piotrmurach

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 avatar Oct 10 '23 12:10 jimbali

@jimbali That's life and the show must go on. You didn't have to but thank you. Appreciate your kindness. 🙏

piotrmurach avatar Oct 10 '23 17:10 piotrmurach