webmock icon indicating copy to clipboard operation
webmock copied to clipboard

Start connection in `Net::HTTP` adapter for mocked requests

Open ojab opened this issue 3 years ago • 5 comments

Instrumentation like Sentry only instruments requests when Net::HTTP.started? because #request is called twice if connection is not started yet. This change allows this instrumentation to work with mocked requests.

See https://github.com/ruby/net-http/blob/master/lib/net/http.rb#L1529-L1534

ojab avatar Dec 10 '21 16:12 ojab

Ready to review because CI waits for approval, rspec spec/acceptance/net_http/ is green locally.

ojab avatar Dec 10 '21 16:12 ojab

@ojab I'm sorry for the delay.

Is that related specifically to Sentry which checks for Net::HTTP.started? . My concern is that in all other cases it will unnecessarily call request twice without any specific need.

bblimke avatar Aug 02 '22 12:08 bblimke

Sentry prompted me to look into that and I didn't saw any issues about it in other places, but overall it should make mocking more correct and shouldn't bring much overhead.

ojab avatar Aug 02 '22 12:08 ojab

#992 also fixes this, if I'm not mistaken.

rzane avatar Aug 08 '22 22:08 rzane

@ojab is this PR still required since https://github.com/bblimke/webmock/pull/992 has already been released?

bblimke avatar Aug 19 '23 11:08 bblimke