discourse / mini_mime

minimal mime type library
MIT License
95 stars 33 forks source link

Random read failures #59

Open kangguru opened 2 months ago

kangguru commented 2 months ago

Hej there. So here's what is happening in our application:

We're sending out some mails via delayed_job and action_mailer like many other apps are likely doing, these mails contain urls to images stored with active_storage. Every now and then building the mail templates is failing with obscure errors happening in mini_mime. These are:

When we try those calls in a console ... everything works. When we stare at the problem ... it disappears :)

It kind of looks vaguely familiar to https://github.com/discourse/mini_mime/issues/37 but that might be misleading.

So, long speech :) Do you have any idea why this could be happening? Any thoughts and ideas are welcome.

Thanks!

gee-forr commented 1 week ago

Hey there, I just want to confirm I'm seeing the same issue on my side. I've locked mini_mime to 1.1.2 in the meantime, which works fine for now:

gem 'mini_mime', '= 1.1.2'

I'm on Ruby 3.0.6 (both ARM and x86 versions), running via Rails 6.1.7.8 (I know, I know, we're due to upgrade soon :) ).

I'm somewhat luckier than you @kangguru as my failures are repeatable during rspec runs. This is a sample of my test failure. Interesting bit is the last 4 lines

  5) NoImsiReportMailer#send_email when a user has not been specified notifies the exception handler of an error
     Failure/Error: ExceptionHelper.error e
       ExceptionHelper received :error with unexpected arguments
         expected: (NoMethodError)
              got: (#<EOFError: end of file reached>)
       Diff:
       @@ -1 +1 @@
       -[NoMethodError]
       +[#<EOFError: end of file reached>]
     # ./app/mailers/no_imsi_report_mailer.rb:10:in `rescue in send_email'
     # ./app/mailers/no_imsi_report_mailer.rb:2:in `send_email'
     # ./spec/mailers/no_imsi_report_mailer_spec.rb:53:in `block (4 levels) in <top (required)>'
     # ./spec/rails_helper.rb:71:in `block (3 levels) in <top (required)>'
     # /gems/ruby/3.0.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/strategy.rb:30:in `cleaning'
     # /gems/ruby/3.0.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:34:in `block (2 levels) in cleaning'
     # /gems/ruby/3.0.0/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:35:in `cleaning'
     # ./spec/rails_helper.rb:70:in `block (2 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # EOFError:
     #   end of file reached
     #   /gems/ruby/3.0.0/gems/mini_mime-1.1.5/lib/mini_mime.rb:121:in `readline'