-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turbo::Streams::BroadcastStreamJob
raising ActiveJob::SerializationError
with ActiveSupport::SafeBuffer
#522
Comments
Huh, for some reason the error's not showing up on my app anymore. |
The error comes from using Sidekiq with strong arguments. It's still present. |
The underlying issue here might've been resolved by rails/rails#50122. It's only 1 week old at this point (Nov 30, 2023), so depending on your version of Rails, that might not be a meaningful fix for some time. With that fix in mind, I wonder if it'd be viable for the engine to conditionally package an ActiveJob::Serializers::ObjectSerializer extension to special case |
That must be why it was fixed for me! We're running on Rails edge. If there's a chance the Rails team will backport the fix, I could ask. If they probably won't, then I'll add the monkey-patch. |
Ah, I'm getting this error again when using Sidekiq. |
Will revert once hotwired/turbo-rails#522 is closed.
@seanpdoyle it looks like rails/rails#50122 didn't actually add a serializer for |
It's possible I'm doing this wrong but adding the serializer didn't resolve it. Here's my initializer: # frozen_string_literal: true
class SafeBufferSerializer < ActiveJob::Serializers::ObjectSerializer
def serialize(argument)
super({ 'value' => argument.to_s })
end
def deserialize(hash)
ActiveSupport::SafeBuffer.new(hash['value'])
end
private
def klass
ActiveSupport::SafeBuffer
end
end
ActiveJob::Serializers.add_serializers(SafeBufferSerializer) And this still triggers the error:
Even if this somehow did work, it would invariably be slower than converting the Edit: the above wasn't working on 7.1.2. It does, however, work on Rails edge but |
I used the workaround by @northeastprince
Just so I could play with this new toy. Wow! 🤯 I can't wait till this is production ready! |
This provides compatibility with Sidekiq as an ActiveJob adapter (because [Sidekiq only allows native JSON types][1] to be passed as job arguments). All credit goes to [@jdelStrother] who [suggested this solution][2]. Fixes [hotwired#522] and [hotwired#535] [1]: https://github.com/sidekiq/sidekiq/wiki/Best-Practices#1-make-your-job-parameters-small-and-simple [2]: hotwired#535 (comment) [@jdelStrother]: https://github.com/jdelStrother [hotwired#522]: hotwired#522 [hotwired#535]: hotwired#535
The callbacks defined using
broadcasts_refreshes
(from 2.0.0-beta.1) fail withThe text was updated successfully, but these errors were encountered: