Add support for Rack 3 (fix "unable to connect")#56
Open
dan-jensen wants to merge 1 commit intohashrocket:masterfrom
Open
Add support for Rack 3 (fix "unable to connect")#56dan-jensen wants to merge 1 commit intohashrocket:masterfrom
dan-jensen wants to merge 1 commit intohashrocket:masterfrom
Conversation
Handler definitions have moved from Rack to Rackup in Rack 3. This modifies config.ru to look for a new Rackup handler before falling back to an old Rack handler.
Contributor
Author
|
@dillonhafer @avogel3 could one of you guys review and merge? This one is more critical than other pending PRs because it fixes a problem that is difficult to trace back to capybara-webmock after upgrading to Rack 3. Thankfully it's a simple fix, so hopefully a quick review and merge if you have a minute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Upgrading to Rack 3+ causes calls to
Capybara::Webmock.startto fail with "RuntimeError: Unable to connect to capybara-webmock proxy on 9292" (followed by "EOFError: end of file reached" for subsequent tests in the rspec run).That happens because this gem's config.ru file calls
Rack::Handler::WEBrick, which no longer exists as of Rack 3. It has been moved to Rackup (Rackup::Handler::WEBrick).Solution
This modifies config.ru to look for a new Rackup handler before falling back to an old Rack handler.
This uses the same syntax used in capybara since 2023-10-08.
We missed the deprecation period because the warnings emitted in stdout don't get displayed. Likewise, now this is raising an error, we can't see the error messages. I found the problem by adding
puts stdout.readand discovering the error message.