zombocom/derailed_benchmarks

Failures in Rails 6 Require

Closed this issue · 4 comments

It looks like this code causes the require to not get fired in our core extension https://github.com/rails/rails/blob/192df82f0d96db48a080fc71ef203979f30b4d08/activesupport/lib/active_support/dependencies.rb#L238-L244

That is applied to Object.

You can see a failure in #148 on https://travis-ci.org/schneems/derailed_benchmarks/jobs/590138082#L412-L417

The high level require does not get triggered.

Even if I replace my core extension with this it does not fire:

module Kernel
  module_function # rubocop:disable Style/ModuleFunction

  alias_method(:require_without_derailed, :require)
  def require(path)
    raise "require"
  end

  alias_method(:require_relative_without_derailed, :require_relative)
  def require_relative(path)
    raise "require_relative"
  end

  alias_method(:load_without_derailed, :load)
  def load(path, wrap = false)
    raise "load"
  end
end

class Module
  alias_method(:autoload_without_derailed, :autoload)
  def autoload(const, path)
    raise "autoload"
  end
end

No idea how bootsnap is working around this in https://github.com/Shopify/bootsnap/blob/master/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb. Either they're not and are silently getting this error or they've mitigated it somewhere.

Opened Rails issue rails/rails#37308

And one in bootsnap Shopify/bootsnap#275

Fixed in #150

The issue was that we were making a method to be not-private by accident which triggers the failure mode in Rails (if I recall correctly).