rails / solid_queue

Database-backed Active Job backend
MIT License
1.95k stars 130 forks source link

source sequence is illegal/malformed utf-8 using mailer deliver_later #387

Closed facedo closed 3 weeks ago

facedo commented 1 month ago

JSON::GeneratorError in NomovimisController#emite_recibos.

I have upgraded from rails 7.0 to rails 7.3.1. All working fine. Installed solid_queue and got that error using deliver_later.

This is the layout: <!DOCTYPE html>

<%= yield %>

Only fails with solid_queue.

rosa commented 3 weeks ago

🤔 This is quite strange as Solid Queue relies on Active Job for serialization and deserialization and job execution. How were you running the jobs before?

facedo commented 3 weeks ago

Solved: Before: pdf = RepEstudioInforme.new(cabeza: estudio, titulo: titulo) UserMailer.with(estudio_id: estudio.id, asunto: titulo, anexo_nombre: nombre_archivo, anexo_data: pdf.render).diagnostico_email.deliver_later Now: pdf = RepEstudioInforme.new(cabeza: estudio, titulo: titulo) pdf.render_file anexo UserMailer.with(estudio_id: estudio.id, asunto: titulo, anexo_nombre: nombre_archivo, anexo_path: anexo).diagnostico_email.deliver_later

Thank you.

rosa commented 3 weeks ago

Huh, interesting! So the difference is that you're calling this?

pdf.render_file anexo

It doesn't seem related to Solid Queue at all 🤔

facedo commented 3 weeks ago

I think it is not related, but i discovered it after a lot of searching and found nothing in docs. Simple logical deduction: queues are keeping on db and solis_queue does not handle blobs in storage. The bad thing about that solution is that now i have a lot of files that must delete some time, but they are in tmp/anexos, so is easy. Thanks.

rosa commented 3 weeks ago

Oh, I see it now, yes. You were passing the whole file as parameter to the job, I had missed this parameter:

anexo_data: pdf.render

My guess is that you're running into a column size limitation, and the JSON data being silently truncated, depending on how you have your database configured. I think this might work with other queue systems by chance, but it might be problematic regardless, having such huge parameters passed around in the job. You shouldn't do this even if you use a queue backend that allows it.