pact-foundation / pact-mock_service

Provides a mock service for use with Pact

Home Page:https://pact.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2.8.0 gives "RuntimeError: Rack application timed out during boot"

dreeve opened this issue · comments

I'm curious if there is something I am doing wrong, or if the change to using 0.0.0.0 in #88 is causing other people problems as well.

Issue

I have an application that has been using pact tests for some time. The tests haven't changed between version 2.7.1 and 2.8.0, but I'm now receiving the following error when running rspec tests locally (on OS X):

RuntimeError:
  Rack application timed out during boot

If it's of interest, the mock_service definition that relates to the timeout is very simple, and looks similar to this:

mock_service :friendly_service do
  port 6789
end

My /etc/hosts file seems sensible as well:

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

Investigation

When investigating the timeout, I noticed that the only change between 2.7.1 and 2.8.0 was #88, which added the Host: '0.0.0.0' option to webrick_opts. In addition, the host method in lib/pact/consumer/server.rb is still returning "localhost".

Specifically, it looks like the boot timeout ultimately relies on get_identity -- which creates a new Net::HTTP request with the value of host -- and that localhost and 0.0.0.0 are potentially incongruent.

Changing the return value of the host method to "0.0.0.0" and running the tests again exposed that lib/pact/mock_service/client.rb lines 11 and 44 also needed to be changed from localhost to 0.0.0.0.

At that point, our tests were failing because of our own hard-coded references to http://localhost (with the appropriate port for the related mock server), but after changing these values to 0.0.0.0, all tests pass as they had with version 2.7.1.

For now, we're going to pin pact-mock_service to 2.7.1, but I'm curious if anyone has any ideas!

Sorry, I'll revert that change and put out a new release. We'll work out another way of achieving what was trying to be achieved with the PR that changed it to 0.0.0.0.

I've released 2.8.1 with binding reverted.