Open strayer opened 4 years ago
This seems to be related to net_http_connect_on_start. When adding WebMock.disable_net_connect!(net_http_connect_on_start: true)
to the webmock initializer in my example project, the proxy requests work again. Reading the README I don't see any negative side effects of setting this, so I assume this is a reasonable workaround for this use case.
Thanks for submitting the issue.
Webmock also modifies Net::HTTP therefore it doesn't play nicely with other libraries that modify Net::HTTP as well.
rack-proxy (0.6.5) lib/net_http_hacked.rb:50:in
begin_request_hacked'`
In case anyone else comes across this, I've added the following monkey patch, which works for my test case:
module WebMock
module HttpLibAdapters
class NetHttpAdapter
@webMockNetHTTP.define_method(:begin_request_hacked) { |req| request(req) }
end
end
end
This is related to https://github.com/bblimke/webmock/issues/374
We use rack-reverse-proxy to access our webpack-dev-server when running the tests. Since there is some kind of conflict between rack-proxy (used by rack-reverse-proxy) and webmock I decided to open a new issue specific to this use-case – I hope you don't mind.
As soon as webmock is added to the mix, something in rack-proxy or Net::HTTP seems to break, although I'm not able to grasp the specific root of the problem.
I created a very simple Rails app that demonstrates the issue: https://github.com/Strayer/rack-proxy-webmock-conflict
To reproduce the issue, simply start the server (
rails s
) and then try to access something in the reverse-proxy URL:curl http://localhost:3000/gh/README.md
The request will fail with this stacktrace: