-
Notifications
You must be signed in to change notification settings - Fork 427
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
ActiveJob::SerializationError: Unsupported argument type: StringIO #319
Comments
@the-teacher I was able to reproduce the issue. As you mentioned above, there is no easy way of using The real problem is the way the email is created and how When the environment section for the notification email is generated, it includes this: which seems to be the culprit. Anyway I will investigate more and try to find a workaround to send emails in the background since it seems to be a good feature to support. |
When serializing,
Furthermore I thinks this leaves a few questions open.
|
@Axxiss Did you find answers of your question? :) I have similar questions and got stuck. |
@aruprakshit No, I didn't had a chance to look further into it. |
This should be a great addition. I was wondering if it would be possible to serialize the data used in the views. I'm not familiar with the source code, but if anyone point me a direction I can give a shoot. |
I ran into this exact issue in my application. It turned out the cause is ActiveJob saving parameters to later call the original method. My solution is to use module ExceptionNotifier
class EmailNotifier
def call(exception, options={})
create_email(Marshal.dump([ exception, options ])).deliver_later
end
def create_email(params)
super(*Marshal.load(params)))
end
end
end Nice thing is that the (un)marshalling can be there even for non-delayed delivery. I hope this helps someone. :c) |
@xHire I did that way you did. But while loading sometime I was getting encoding error. |
@aruprakshit That’s interesting. Could you be more specific? Is it a normal Ruby encoding error or something special? For which encodings/contents does it happen? Personally, I didn’t run in any such issue, but that might be because my application only works with ascii-8bit data. |
2018, still looking for a way to have notifications perfomed by sikekiq... Trying all solutions above, don't find something working yet. It's gonna end with a custom message base on |
Hi, I just got stuck with this. I tried many things, so far this is the best approach I have: module EmailNotifier
def call(exception, options = {})
options[:env] = options[:env].transform_values do |value| # this could be in a pre_callback?
break if ActiveJob::Serializers.serializers.include? value.class
value.to_s
end
super(exception, options)
end
end The problem with this approach, is have to write the serializers (see) for the classes that will used later for construct the body of email, (e.g. controller classes) and then add to active job serializers array. And only will work for Rails > 6. Another approach its serialize to hashes the exception and options just before call deliver_later (maybe the email will have less info about the error). What do you think? |
This also hit me in a new Rails 6.1 app. Being able to deliver exception notifications in the background is important, and we use Sidekiq to back ActiveJob. I haven't found a good solution yet. |
Would love to get a fix for this @juanazam! Thanks |
+1 |
A slightly modified @kadru's version that worked for us on rails 6.1 config/initializers/exception_notifier.rb module ExceptionNotifier
# ...
class EmailNotifier < BaseNotifier
def call_with_patch(exception, options = {})
options[:env] = options[:env].transform_values do |value|
break if ActiveJob::Serializers.serializers.include? value.class
value.to_s
end
call_without_patch(exception, options)
end
alias_method(:call_without_patch, :call)
alias_method(:call, :call_with_patch)
# ...
end
end |
Hello!
I am looking for way how to put sending notifications to the background.
I tried play with
exception_notification (4.1.4)
. I found option for email notificationsdeliver_with
but it looks like allow the justdeliver_now
value.Fine, I wrote following monkey patch for my test app:
config/initializers/exception_notifier_patch.rb
And I have an error message for Sidekiq:
So, for me it looks like
create_email
do something incorrect for delayed processors. Maybe DelayedJob can process this, but Sidekiq can't.I want to ask, is it possible to put
exception_notification
mailers to sidekiq queue? Or maybe it's impossible for now, and I should stop my attempts?Thanks for any advice!
The text was updated successfully, but these errors were encountered: