Don't swallow Exception if load_model fails

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: Associations, Persistence
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      As outlined in https://github.com/mongodb/mongoid/discussions/5418, allowing Rails to continue booting if a model preload fails could have adverse consequences.

      One potential mitigation would be to alter Rails::Mongoid.load_mode as follows:

          def load_model(file)
            begin
              require_dependency(file)
            rescue SignalException => e
              Logger.new(STDERR).warn("Received signal #{e.message}, raising")
              raise
            rescue Exception => e
              Logger.new(STDERR).warn(e.message)
            end
          end
      

      Another option would be to rescue StandardError instead of Exception

              Assignee:
              Unassigned
              Reporter:
              Alex Bevilacqua
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: