Skip to content

Rails 8.1 deprecation warnings for LoadInterlockAwareMonitor during DSL generation #2463

@amilligan

Description

@amilligan

Description

When running tapioca dsl with Rails 8.1, five deprecation warnings are emitted:

DEPRECATION WARNING: ActiveSupport::Concurrency::LoadInterlockAwareMonitor is deprecated and will be removed in Rails 9.0. Use Monitor directly instead, as the loading interlock is no longer used.

Root Cause

Rails 8.1 deprecated ActiveSupport::Concurrency::LoadInterlockAwareMonitor by replacing it with a DeprecatedConstantProxy. This proxy emits a deprecation warning whenever the constant is accessed - even for inspection.

During DSL RBI generation, Tapioca's compilers iterate over all loaded modules and constants via all_modules.select { ... } in gather_constants methods. When these compilers encounter LoadInterlockAwareMonitor, simply accessing the constant triggers the deprecation warning.

The warnings originate from these compilers:

  • Tapioca::Dsl::Compilers::ActiveSupportConcern (lines 73-76)
  • Tapioca::Dsl::Compilers::MixedInClassAttributes (line 72-73)
  • Tapioca::Dsl::Compilers::UrlHelpers (lines 119-125)

Reproduction Steps

  1. Create a Rails 8.1 application with Sorbet/Tapioca
  2. Run bin/tapioca dsl
  3. Observe the deprecation warnings in output

Expected Behavior

tapioca dsl should run without emitting deprecation warnings for deprecated constant proxies that are merely being enumerated.

Environment

  • Tapioca version: 0.17.10
  • Rails version: 8.1.1
  • Ruby version: 3.4.7

Possible Solutions

  1. Filter out DeprecatedConstantProxy constants - In the gather_constants methods, check if a constant is a DeprecatedConstantProxy before accessing it for inspection
  2. Silence deprecations during constant enumeration - Wrap the constant enumeration in ActiveSupport.deprecator.silence { ... }

Workaround

As a temporary workaround, projects can add a custom deprecation behavior in a Rails initializer:

original_behaviors = ActiveSupport.deprecator.behavior.dup
ActiveSupport.deprecator.behavior = -> (message, callstack, deprecator) do
  return if message.to_s.include?("LoadInterlockAwareMonitor")

  original_behaviors.each do |behavior|
    behavior.call(message, callstack, deprecator)
  end
end

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions