bblimke / webmock

Library for stubbing and setting expectations on HTTP requests in Ruby.
MIT License
3.97k stars 556 forks source link

Issues on localhost connection #1004

Closed alienxp03 closed 1 year ago

alienxp03 commented 2 years ago
An HTTP request has been made that VCR does not know how to handle:
  DELETE http://127.0.0.1:9515/session/ba2fca9d59c2f4252a8a21f6f505ceae

  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/vcr-6.0.0/lib/vcr/library_hooks/webmock.rb:129:in `on_unhandled_request'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/vcr-6.0.0/lib/vcr/request_handler.rb:24:in `handle'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/vcr-6.0.0/lib/vcr/library_hooks/webmock.rb:144:in `block in <module:WebMock>'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/stub_registry.rb:33:in `block (2 levels) in register_global_stub'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/stub_registry.rb:39:in `synchronize'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/stub_registry.rb:39:in `block in register_global_stub'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/request_pattern.rb:40:in `matches?'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/stub_registry.rb:73:in `block in request_stub_for'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/stub_registry.rb:72:in `each'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/stub_registry.rb:72:in `detect'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/stub_registry.rb:72:in `request_stub_for'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/stub_registry.rb:64:in `response_for_request'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/http_lib_adapters/net_http.rb:74:in `request'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:129:in `response_for'
  from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:82:in `request'
require 'vcr'
require 'webmock/rspec'

WebMock.disable_net_connect!(allow_localhost: true)
WebMock.allow_net_connect!(net_http_connect_on_start: %w(localhost 127.0.0.1))

VCR.configure do |config|
  config.cassette_library_dir = "spec/vcr_cassettes"
  config.hook_into :webmock, :excon, :faraday
  config.configure_rspec_metadata!
  config.ignore_localhost = true
  config.default_cassette_options = { record: ENV.fetch('VCR', 'none').to_sym, erb: true }
end

Although the error mentioned something about VCR, the stack-trace is showing that it's started from from /home/runner/work/app/vendor/bundle/ruby/2.5.0/gems/webmock-3.18.1/lib/webmock/http_lib_adapters/net_http.rb:74:inrequest'`. At the moment it's pretty hard to debug since it's only happening on Github Action CI, however it's working fine in DroneCI (in the middle of transition to Github at the moment).

The issue is randomly happening on CI, not specific to any test cases, or Capybara. Same issue is happening on localhost:9200, which is for our Elasticsearch test.

My setup is pretty straightforward too. Is there a way to reliably test this so I can create a proper bug report?

bblimke commented 1 year ago

@alienxp03 is this still an issue? can you still reproduce it?

alienxp03 commented 1 year ago

No longer working on the project so can't reproduce it for now. Will close the issue.