Skip to content

Comments

Fixup code for use with rackup gem (may be used with rack 3) (#3061)#10

Open
MitchLewis930 wants to merge 1 commit intopr_060_beforefrom
pr_060_after
Open

Fixup code for use with rackup gem (may be used with rack 3) (#3061)#10
MitchLewis930 wants to merge 1 commit intopr_060_beforefrom
pr_060_after

Conversation

@MitchLewis930
Copy link

PR_060

* Fixup code for use with rackup gem (may be used with rack 3)

* Update rack_default.rb

* Update puma.rb, use `include` instead of `module_eval`

* Changes per comments
@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 01:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Puma codebase to support both the legacy Rack 2 handler pattern and the newer rackup gem (used with Rack 3), where the rackup functionality was extracted into a separate gem.

Changes:

  • Introduced conditional module selection based on environment variable to use either Rack::Handler or Rackup::Handler
  • Refactored handler code to use a shared Puma::RackHandler module included in both Rack::Handler::Puma and Rackup::Handler::Puma
  • Updated Gemfile to conditionally require the rackup gem when not using Rack 2

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
test/test_rack_handler.rb Wraps tests in TestRackUp module and uses RACK_HANDLER_MOD constant to reference the appropriate handler module based on environment
lib/rack/handler/puma.rb Extracts shared handler logic into Puma::RackHandler module and conditionally defines handlers for both Rack 2 and rackup gem
lib/puma/rack_default.rb Adds conditional logic to define default handler for both Rack 2 and rackup gem scenarios
Gemfile Conditionally includes rackup gem dependency when not testing with Rack 2

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

:Silent => false
}

def config(app, options = {})
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methods in the Puma::RackHandler module should be defined with self. prefix or use module_function to ensure they work correctly when included via class << self. Currently these are instance methods, but they're being included into singleton classes and called as class methods. Consider using module_function :config, :run, :valid_options, :set_host_port_to_config after the method definitions to make them work properly as both instance and module methods.

Copilot uses AI. Check for mistakes.
end
end
else
raise "You must install the rackup gem when using Rack 3"
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message should be more actionable by specifying how to install the rackup gem. Consider changing to: 'You must install the rackup gem when using Rack 3. Run: gem install rackup'

Suggested change
raise "You must install the rackup gem when using Rack 3"
raise "You must install the rackup gem when using Rack 3. Run: gem install rackup"

Copilot uses AI. Check for mistakes.
end
end
else
raise "Rack 3 must be used with the Rackup gem"
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message should be more actionable and consistent with the error message in lib/rack/handler/puma.rb. Consider changing to: 'Rack 3 must be used with the rackup gem. Run: gem install rackup'

Suggested change
raise "Rack 3 must be used with the Rackup gem"
raise "Rack 3 must be used with the rackup gem. Run: gem install rackup"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants