testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Failed to find a DNS-record for the resource

Open pablorivera opened this issue 9 years ago • 22 comments

Are you requesting a feature or reporting a bug?

Bug

What is the current behavior?

Tests randomly fails with the following error message: Failed to find a DNS-record for the resource at "https://develop-i.quid.com/". I have seen similar errors reported at https://github.com/DevExpress/testcafe/issues/1135 and https://github.com/DevExpress/testcafe/issues/1601

What is the expected behavior?

Tests doesn't fail with this random error.

Specify your

  • operating system: MacOs Sierra 10.12.6
  • testcafe version: 0.17.2
  • node.js version: v8.1.2

pablorivera avatar Sep 20 '17 18:09 pablorivera

@pablorivera But website is indeed unreachable:

❯ ping develop-i.quid.com 
PING develop-i.quid.com (10.4.0.222): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
^C
--- develop-i.quid.com ping statistics ---
7 packets transmitted, 0 packets received, 100.0% packet los

I guess the problem here is that we report incorrect network error message here. But as far as I remember we use error provided by Node, so it may be a problem on Node side as well.

inikulin avatar Sep 20 '17 19:09 inikulin

Currently this error means that TestCafe was unable to reach the specified website. It is not related only to DNS resolving issues, because it is displayed on any network error: #1606. Likely it's a problem with network connection or with the server. You can use the curl utility to check it: run several times curl http://develop-i.quid.com -o /dev/null. it should not report errors if network connection is working stable.

AndreyBelym avatar Sep 21 '17 10:09 AndreyBelym

won't it be better to ignore this kind of errors or warn them rather stopping test execution completely. I am still having this issue even after DevExpress/testcafe-hammerhead#1216 got resolved.

thecodejack avatar Sep 22 '17 09:09 thecodejack

We can't ignore this error, because it means TestCafe cannot access the test page, there is no network connection or webserver is not responding. The only option here is to retry to fetch the page several times and hopefully some attempt will be successful.

AndreyBelym avatar Sep 22 '17 10:09 AndreyBelym

Thanks @AndreyBelym. I run it multiple times and always get something like this:

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2423    0  2423    0     0   2286      0 --:--:--  0:00:01 --:--:--  2288

Seems to be ok. Do you think there could be another problem?

pablorivera avatar Sep 22 '17 17:09 pablorivera

@AndreyBelym I agree if its the page that's failing. But for me its some script/css from page which is failing which may not be important for the test executions.

thecodejack avatar Sep 25 '17 07:09 thecodejack

I am having similar issues. I deploy a React app as a static website on AWS S3 and I get every now and then (5% of the builds):

   1) - Error while restoring configuration after Role switch -
      Failed to find a DNS-record for the resource at
      "http://mybucketname.s3-website-eu-west-1.amazonaws.com".

cgcote avatar Sep 28 '17 09:09 cgcote

Speaking on behalf of @pablorivera to which i work with.

The develop-i.quid.com is a vpn protected address. Of course it is not accessible from outside. Apologies about that.

I've been digging on this problem a bit, let me add some context:

  1. our app does various window.location.href="http://otherdomain during a single test
  2. the problem is intermittent

By digging into hammerhead code found that the generic error about DNS resolution is trigger for a bigger set of connection problems about connection refused, or connection reset.

With the architecture of having browser -> hammerhead -> testcafe and browser being redirected with window.location.href i guess that when the browser closes an existing in filght ajax due to a js triggered redirect, hammerheads gets upset and fails the test.

This issue is very similar to #1135 and the failure rate gets lower if we increase the time in t.wait() calls before the application switches to another page with a window.location.href call.

Let me know if this helps understanding the problem.

vampolo avatar Oct 02 '17 21:10 vampolo

Thanks for you for your investigation @vampolo, the problem definitely relates to hammerhead, but AFAIK this code should not affect XHR requests. Anyway we will look at this part closely, thank you!

AndreyBelym avatar Oct 03 '17 08:10 AndreyBelym

Hi @pablorivera

Try the latest TestCafe version ([email protected]) and let us know your results. If there is a possibility to hold a remote session using Skype or TeamViewer to access your app, we would be happy to do this.

miherlosev avatar May 03 '18 15:05 miherlosev

Is there a way to change the retry count / number of retries TestCafé does behind the scenes?

aphofstede avatar Nov 06 '18 20:11 aphofstede

@aphofstede, could you please share more details about your problem? What are your operating system and Node.js versions? Does it happen sporadic or in every build, in a specific test or a random one? Can you provide a complete test report or an example that can be used to reproduce the problem?

TestCafe doesn't retry any requests by default, but you can try to enable the undocumented pageRetryMode mode. When this mode is enabled. TestCafe retries failed requests to test pages up to 5 attempts with 300 milliseconds delay between each failed attempt. There are no options to configure the maximum attempts count or the delay between failed attempts.

Currently, you can't enable this mode from the command line interface; you should supply the true Boolean value as the 5th argument of the createTestCafe function to enable this mode. You also can configure your web server to send the Cache-Control header with a big expiration time (e.g., max-age=3600) to get maximum effect from this mode.

AndreyBelym avatar Nov 08 '18 17:11 AndreyBelym

In my case it's running headless in a Docker container. Latest node 10. It's inherently a sporadic issue; it seems like in a (I guess) busy environment, Docker containers' internal DNS can flake out. I've seen it locally with docker-compose and remote on http://buddy.works. It would be nice to have the option you mention as a command line argument so we can easily switch it on in a CI/CD pipeline setup. If the issue comes up again I'll give your suggestions a try, thanks.

aphofstede avatar Nov 09 '18 10:11 aphofstede

I'm having this issue as well.

Failed to find a DNS-record for the resource at "http://localhost:3000/"

Failed to find a DNS-record for the resource at "http://localhost:3000/someResource.jpg"

Running tests in Jenkins/K8/Docker/Linux, headless Firefox & Chrome. Tests are browsing a localhost dev server (create-react-app/webpack). Using both browsers or increasing concurrency (-c X) seems to make the error appear more often.

So not sure if it's hammerhead or the dev server not keeping up, but would be really helpful to be able to enable that retry functionality from command line. Ideally the delay should also be configurable.

jmullo avatar Jan 10 '19 17:01 jmullo

Hi, currently we're facing this issue too. Our behavior is similar than @jmullo and @cgcote, the issue is displayed in 5% of our builds and is triggered randomly.

We're running testcafé in a EC2 machine and sometimes the issue is triggered for some test cases.

We're using 0.22.0 and 0.23.3-alpha.4 versions (The last one to avoid an issue you fixed for mobile devices).

1) - Error in fixture.beforeEach hook - Failed to find a DNS-record for the resource at "http://localhost:5000/". Browser: Chrome 70.0.3538 / Windows 10.0.0 Another example

1) Failed to find a DNS-record for the resource at "http://localhost:5000/". Browser: Firefox 62.0.0 / Windows 10.0.0

For the server we're running a single instance of nodejs with express

hd-esteban avatar Jan 17 '19 22:01 hd-esteban

Has anyone tried --quarantine-mode ?

I've added my experience/suggestion to here: https://github.com/DevExpress/testcafe/issues/3304

kel30a avatar Feb 26 '19 00:02 kel30a

@kel30a @Esteban26 and everyone   The problem does not relate to TestCafe. There are numerous reasons a web page cannot be loaded: a virtual amazon machine is not available, a DNS resolving problem or something else).   You can run your tests in quarantine mode.

miherlosev avatar Feb 26 '19 11:02 miherlosev

I just hit this - the error message is unhelpful since it suggests a DNS problem, when actually it is a connectivity issue. I changed my host to 127.0.0.1 and it still said there was a DNS problem.

pwaller avatar Feb 26 '19 11:02 pwaller

@pwaller yes, there is the only one error message type for all types of network problems. We plan to change the situation in the context of #3492.

AndreyBelym avatar Mar 06 '19 13:03 AndreyBelym

I'm wondering it this issue should really be closed - it occurs to us with every testcafe version we were using so far. We're hosting our app using npm package 'http-server' on localhost, so there is no way it's DNS or connectivity issue.

As for others it's around 5% of cases.

bbonczek avatar Apr 01 '21 11:04 bbonczek