Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: require rack/handler for rack >= 3.1.x #1383

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/tapioca
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ end
require "rubygems"
require "bundler/setup"

ENV['BOOTSNAP_CACHE_DIR'] ||= File.expand_path("../demo/tmp/cache/bootsnap", __dir__)
load Gem.bin_path("tapioca", "tapioca")
12 changes: 11 additions & 1 deletion lib/good_job/probe_server/webrick_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ def initialize(app, options = {})
@app = app
@port = options[:port]
@logger = options[:logger]
@handler = ::Rack::Handler.get('webrick')

# Workaround for rack >= 3.1.x as auto-loading of rack/handler was removed.
# We should move to rackup in the long run.
# See https://github.com/rack/rack/pull/1937.
@handler = begin
require 'rackup/handler'
::Rackup::Handler.get('webrick')
rescue LoadError
require "rack/handler"
::Rack::Handler.get('webrick')
end
end

def stop
Expand Down
53 changes: 53 additions & 0 deletions sorbet/rbi/shims/rackup.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Manually exported via Tapioca because rackup is not compatible with Rack 2.0
# which is used for development, but Rackup is is necessary as a fallback for
# Rack 3.0 compatibility. And Rackup 1.0 is bugged.
#
# https://github.com/rack/rackup/issues/13#issuecomment-2186788166

module Rackup; end
module Rackup::Handler
class << self
# source://rackup//lib/rackup/handler.rb#30
def [](name); end

# source://rackup//lib/rackup/handler.rb#84
def default; end

# source://rackup//lib/rackup/handler.rb#40
def get(name); end

# Select first available Rack handler given an `Array` of server names.
# Raises `LoadError` if no handler was found.
#
# > pick ['puma', 'webrick']
# => Rackup::Handler::WEBrick
#
# @raise [LoadError]
#
# source://rackup//lib/rackup/handler.rb#69
def pick(server_names); end

# Register a named handler class.
#
# source://rackup//lib/rackup/handler.rb#18
def register(name, klass); end

# Transforms server-name constants to their canonical form as filenames,
# then tries to require them but silences the LoadError if not found
#
# Naming convention:
#
# Foo # => 'foo'
# FooBar # => 'foo_bar.rb'
# FooBAR # => 'foobar.rb'
# FOObar # => 'foobar.rb'
# FOOBAR # => 'foobar.rb'
# FooBarBaz # => 'foo_bar_baz.rb'
#
# source://rackup//lib/rackup/handler.rb#106
def require_handler(prefix, const_name); end
end
end

# source://rackup//lib/rackup/version.rb#7
Rackup::VERSION = T.let(T.unsafe(nil), String)
Loading