-
Notifications
You must be signed in to change notification settings - Fork 156
Description
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
- Create a Rails 8.1 application with Sorbet/Tapioca
- Run
bin/tapioca dsl - 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
- Filter out DeprecatedConstantProxy constants - In the
gather_constantsmethods, check if a constant is aDeprecatedConstantProxybefore accessing it for inspection - 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
endRelated
- Rails PR that deprecated the class: after_commit callbacks on model with has_many_attached no longer able to detect new attachments rails/rails#53452