fxn/zeitwerk

Help debugging issue with Zietwerk, gruf and rails

heyZeus opened this issue · 1 comments

I realize this probably isn't a zeitwerk issue, but looking for some help in order to debug an issue with upgrading a bunch of components in my application: Rails (7.0.3.1), zeitwerk (2.6.0) and gruf (2.15.1).

When I start a gruf server bundle exec gruf and make any calls to our GRPC endpoints, I'm receiving an error message like:

can't reload, please call loader.enable_reloading before setup

The gruf initializer looks like this:

require 'gruf'
require 'gruf_logger'

Dir[Rails.root.join('app', 'controllers', 'rpc', '*')].each { |f| require f }

Gruf.configure do |c|
  c.server_binding_url = Rails.configuration.service_discovery['server']
  c.logger = Rails.logger
  c.grpc_logger = Rails.logger
  c.interceptors.use(
    Gruf::Interceptors::Instrumentation::RequestLogging::Interceptor,
    formatter: GrufLogger.new(service_name: 'cqc-gruf'),
    blacklist: %w[packages documents],
    log_parameters: true
  )
end

From our logs we see that the gruf server appears to start ok:

[gruf] Binding My::Classification::Service to Rpc::ClassificationController
[gruf] Binding My::Classification::Service to Rpc::ClassificationController
[gruf] Starting gruf server at 127.0.0.1:9011...
[gruf] Binding My::Classification::Service to Rpc::ClassificationController

No where in our codebase do we call the zeitwerk loader or call loader.setup. The error that we are seeing never appears in the server log, but only when a gruf client makes the call to any of the endpoints. When we downgrade just zeitwerk, we still see this error. Also, we only see this error for local development and never in a deployed environment.

Any help/advise with debugging this issue would be greatly appreciated. Thanks!

I downgraded the gruf gem back to gruf (= 2.14.1) and the issue has gone away. It would appear this gem is not quite compatible and was causing the issue. Thanks.