Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCR still tries to open TCP connection when using cassette #943

Open
TomNaessens opened this issue Jun 23, 2022 · 1 comment
Open

VCR still tries to open TCP connection when using cassette #943

TomNaessens opened this issue Jun 23, 2022 · 1 comment

Comments

@TomNaessens
Copy link

TomNaessens commented Jun 23, 2022

Hello,

I'm experiencing an issue where VCR still tries to open a TCP connection when using a cassette, even though the cassette is used to replay the response.

I believe the issue is related to the interaction between VCR and WebMock. In our configuration, we disable the net_http_connect_on_start setting of WebMock (https://github.com/bblimke/webmock#connecting-on-nethttpstart) to get around an issue with Capybara (see last point of https://github.com/teamcapybara/capybara#gotchas).

However, when net_http_connect_on_start is enabled, there are still requests "to the outside world" happening when using a cassette. As I can't reach that endpoint, the tests fail with the following error:

ActionView::Template::Error: Failed to open TCP connection to [redacted].my.salesforce.com (getaddrinfo: nodename nor servname provided, or not known)

Using Wireshark, I can see that the requests still happen (and fail):

1397	60.862527	2a02:1812:1437:b700:9164:b508:190c:1dc2	2a02:1800:100::42:2	DNS	116	Standard query 0x89ea A [redacted].my.salesforce.com
1398	60.862722	2a02:1812:1437:b700:9164:b508:190c:1dc2	2a02:1800:100::42:2	DNS	116	Standard query 0xe21d AAAA [redacted].my.salesforce.com
1399	60.881073	2a02:1800:100::42:2	2a02:1812:1437:b700:9164:b508:190c:1dc2	DNS	169	Standard query response 0x89ea No such name A [redacted].my.salesforce.com SOA dns01.salesforce.com
1400	60.883525	2a02:1800:100::42:2	2a02:1812:1437:b700:9164:b508:190c:1dc2	DNS	169	Standard query response 0xe21d No such name AAAA [redacted].my.salesforce.com SOA dns01.salesforce.com

When I disable net_http_connect_on_start, the tests run (and the VCR is used, otherwise the same issue would occur and I see that the requests are matched in my VCR log).

I'm using:

Ruby 2.7.6p219
vcr (5.0.0) (issue persisted when bumping to 6.1.0)
net-http2 (>= 0.18.3, < 2)
webmock (3.12.2) (issue persisted when bumping to 3.14)
rails (6.1.6)
rspec (3.10.0)

Is this a bug as VCR should never try to reach "the outside world" when using a cassette?

Is this something I can work around in configuration?

@olleolleolle
Copy link
Member

Enabling this feature does tell webmock to do that, and it seems a little involved to make it... not do that.

Source: code search for that term in that repo.

Ready to review any PRs about changing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants