krisleech/wisper

Ruby 3.0 support for broadcast with kwargs

Closed this issue · 14 comments

When broadcasting with kwargs, an ArgumentError is raised in Ruby 3.0:

broadcast(:user_changed, initial_id: user_id_before_last_save, final_id: user_id)
ArgumentError: wrong number of arguments (given 1, expected 0; required keywords: initial_id, final_id)

This worked fine on Ruby 2.6, but because Publisher#broadcast doesn't handle kwargs, it breaks in 3.0.

If anyone else is encountering this, I fixed it by monkey patching wisper on my codebase:

module Wipser
  module Publisher
    # Wisper 2.0.1 does not properly support Ruby 3 kwargs
    def broadcast(event, ...)
      registrations.each do |registration|
        registration.broadcast(clean_event(event), self, ...)
      end
      
      self
    end
  end
end

I'd create a PR but ... won't work for lesser ruby version so I'm not exactly sure what to do.

doits commented

I opened #192 to hopefully make it compatible with ruby 3, needs some more testing though to make sure it really works like intended!

I'd love to get Ruby 3.0 support in Wisper. But it would need to be backwards compatible. Otherwise we would need to release a new major version dropping Ruby 2.x support and maintain both major versions until Ruby 2.x is EOL, which will be a long time.

doits commented

#192 is compatible with >= 2.7, so for all officially supported ruby versions but 2.6. For 2.6 the ruby team writes: In security maintenance phase (will EOL soon!).

The only solution I see to make it compatible with 2.6 and 3 is to use ruby2_keywords. I am not sure if supporting 2.6 is worth the hassle (EOL soon). What do you think?

We can do a major version release which drops support for 2.6, we need to document it in the CHANGELOG, that it is a breaking change.

If anyone wants to pick this up it would be great. We can drop support for EOL Rubies and add Ruby 3 keyword arguments support.

@krisleech - I opened #197 to address this, hopefully. Wondering if you could take a look when you get a chance, thanks!

I think someone should just publish a clone of this that is ruby 3 ready. The wisper-next gem isn't as full-featured yet as this, and the async functionality for that doesn't seem to be ready either.

I think someone should just publish a clone of this that is ruby 3 ready. The wisper-next gem isn't as full-featured yet as this, and the async functionality for that doesn't seem to be ready either. Frustrating.

@benlieb You can create a clone, you can contribute to wisper-next. You could make the changes needed on the PR to allow it to be merged and released. You haven't paid anything for this software, you have no right to complain, zero. You aren't entitled to free labour. Do you or the company you work for donate anything to open source projects?

@krisleech I regret coming off as an entitled whiner. It makes sense that that would be triggering for you, especially as the author. No real excuses, I just remember being short on time and short on options for what I needed that week.

I appreciate your work!

Any news on this?

Just waiting on #197

Anyone on this thread please try #205 on your codebase and report back any issues... We are close to a release if we can get this tested on some production codebases.

wisper 3.0.0.rc1 has been released