Skip to content

Commit

Permalink
Fix Rack version to work across multiple released versions
Browse files Browse the repository at this point in the history
Rack deprecated `Rack.version` and the associated constant
`Rack::VERSION` in v3, to be removed in v3.1. We were getting
the deprecation warnings on our test suite:

    ./judoscale-ruby/judoscale-rack/lib/judoscale/rack.rb:14:
    warning: Rack.version is deprecated and will be removed in Rack 3.1!
    ./gems/rack-3.0.11/lib/rack/version.rb:25:
    warning: constant Rack::VERSION is deprecated

Running on the latest v3.1 version caused them to break:

    ./judoscale-ruby/judoscale-rack/lib/judoscale/rack.rb:14:in `<top (required)>':
    undefined method `version' for module Rack (NoMethodError)

      framework_version: ::Rack.version
                               ^^^^^^^^

Deprecation:
rack/rack@856934f#diff-75f019921d551ec3df0214212140eeda19369f014b93b77a9c92cfa64ec04c16

Removal:
rack/rack@a5762cf#diff-75f019921d551ec3df0214212140eeda19369f014b93b77a9c92cfa64ec04c16

Reintroducing `Rack::VERSION` constant: (which we don't use --
unreleased as of now)
rack/rack@4cfad11
  • Loading branch information
carlosantoniodasilva committed Jun 17, 2024
1 parent bd5126b commit dd0c08c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion judoscale-rack/lib/judoscale/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@

Judoscale.add_adapter :"judoscale-rack", {
adapter_version: Judoscale::VERSION,
framework_version: ::Rack.version
# Rack deprecated `version` in v3, removed in v3.1.
framework_version: ::Rack.respond_to?(:release) ? ::Rack.release : ::Rack.version
}, metrics_collector: Judoscale::WebMetricsCollector

0 comments on commit dd0c08c

Please sign in to comment.