In this commit which is part of Rails 7.1, the default logger changed from Logger to the new BroadcastLogger.
This change causes a sorbet-runtime error because BroadcastLogger does not inherit from Logger and therefore doesn't match the expected type in the signature for the setup method.
This ends up being a weird issue. The BroadcastLogger class was designed to match the same interface as Logger. However, we can't use a Sorbet interface in this case. For an interface to work, it needs to be included in the actual runtime - and Rails won't include a Sorbet construct in the codebase.
Even using T.any(Logger, Rails::BroadcastLogger) wouldn't work properly. This gem has a dependency on Active Support, but using the new BroadcastLogger would create a dependency on Active Support >= 7.1.0, which is probably too new for all consumers of this gem.
Therefore, despite the unfortunate loss in type safety, I think the way forward is to set logger to T.untyped so that we can accept both Logger and BroadcastLogger without creating a dependency on Rails.
This unblocks Rails 7.1 upgrades.
How has this been tested?
Just ran bundle exec rake test.
Checklist:
[x] My commit message follow the pattern described in here
[x] I have performed a self-review of my own code.
[ ] N/A. I have added tests that prove my fix is effective or that my feature works.
[ ] N/A. I have updated the project documentation.
Description
In this commit which is part of Rails 7.1, the default logger changed from
Logger
to the newBroadcastLogger
.This change causes a
sorbet-runtime
error becauseBroadcastLogger
does not inherit fromLogger
and therefore doesn't match the expected type in the signature for thesetup
method.This ends up being a weird issue. The
BroadcastLogger
class was designed to match the same interface asLogger
. However, we can't use a Sorbet interface in this case. For an interface to work, it needs to be included in the actual runtime - and Rails won't include a Sorbet construct in the codebase.Even using
T.any(Logger, Rails::BroadcastLogger)
wouldn't work properly. This gem has a dependency on Active Support, but using the newBroadcastLogger
would create a dependency on Active Support>= 7.1.0
, which is probably too new for all consumers of this gem.Therefore, despite the unfortunate loss in type safety, I think the way forward is to set
logger
toT.untyped
so that we can accept bothLogger
andBroadcastLogger
without creating a dependency on Rails.This unblocks Rails 7.1 upgrades.
How has this been tested?
Just ran
bundle exec rake test
.Checklist: