{"action":"opened","issue":{"url":"https://api.github.com/repos/tjfontaine/node-dns/issues/94","labels_url":"https://api.github.com/repos/tjfontaine/node-dns/issues/94/labels{/name}","comments_url":"https://api.github.com/repos/tjfontaine/node-dns/issues/94/comments","events_url":"https://api.github.com/repos/tjfontaine/node-dns/issues/94/events","html_url":"https://github.com/tjfontaine/node-dns/issues/94","id":60255848,"number":94,"title":"Errors when using the 1:1 mapping of the upstream node.js dns module combined with the platform object","user":{"login":"mdebruijne","id":11375308,"avatar_url":"https://avatars.githubusercontent.com/u/11375308?v=3","gravatar_id":"","url":"https://api.github.com/users/mdebruijne","html_url":"https://github.com/mdebruijne","followers_url":"https://api.github.com/users/mdebruijne/followers","following_url":"https://api.github.com/users/mdebruijne/following{/other_user}","gists_url":"https://api.github.com/users/mdebruijne/gists{/gist_id}","starred_url":"https://api.github.com/users/mdebruijne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdebruijne/subscriptions","organizations_url":"https://api.github.com/users/mdebruijne/orgs","repos_url":"https://api.github.com/users/mdebruijne/repos","events_url":"https://api.github.com/users/mdebruijne/events{/privacy}","received_events_url":"https://api.github.com/users/mdebruijne/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-08T13:08:11Z","updated_at":"2015-03-08T13:08:11Z","closed_at":null,"body":"Hi,\r\n\r\nI have noticed multiple errors when using the 1:1 mapping of the upstream node.js dns module combined with the platform object. This is with node version 0.12 and native-dns version 0.7.0.\r\n\r\nSee below for scripts to reproduce the errors and the output when running these scripts. The only difference between these scripts is the dns.platform.name_servers value.\r\n\r\nI think that the scripts and outputs are self-explanatory, but if more information is required then please let me know.\r\n\r\n---\r\n\r\n```javascript\r\n\"use strict\";\r\n\r\nvar dns = require(\"native-dns\");\r\nvar startTime = process.hrtime();\r\n\r\ndns.platform.attempts = 10;\r\ndns.platform.cache = false;\r\ndns.platform.timeout = 500;\r\n\r\ndns.platform.name_servers = [\r\n  {address: \"8.8.4.4\", port: 53, type: \"udp\"},\r\n  {address: \"8.8.8.8\", port: 53, type: \"udp\"}\r\n];\r\n\r\ndns.resolve(\"www.google.com\", \"A\", function (err, addresses) {\r\n  if (err) {\r\n    console.log(err);\r\n  } else {\r\n    console.log(addresses);\r\n  }\r\n  console.log(\"Process time: %d seconds\", process.hrtime(startTime)[0]);\r\n});\r\n```\r\n\r\n-\r\n\r\n```\r\n$ time node dns.js\r\n  [ '74.125.136.99',\r\n  '74.125.136.106',\r\n  '74.125.136.103',\r\n  '74.125.136.147',\r\n  '74.125.136.105',\r\n  '74.125.136.104' ]\r\nProcess time: 0 seconds\r\n\r\nreal    0m0.201s\r\nuser    0m0.181s\r\nsys     0m0.016s\r\n```\r\n\r\n-\r\n\r\n* expected and current behavior are the same, normal DNS resolving (Baseline)\r\n\r\n---\r\n\r\n```javascript\r\n\"use strict\";\r\n\r\nvar dns = require(\"native-dns\");\r\nvar startTime = process.hrtime();\r\n\r\ndns.platform.attempts = 10;\r\ndns.platform.cache = false;\r\ndns.platform.timeout = 500;\r\n\r\ndns.platform.name_servers = [\r\n  {address: \"127.0.0.1\", port: 53, type: \"udp\"},\r\n  {address: \"8.8.4.4\", port: 53, type: \"udp\"},\r\n  {address: \"8.8.8.8\", port: 53, type: \"udp\"}\r\n];\r\n\r\ndns.resolve(\"www.google.com\", \"A\", function (err, addresses) {\r\n  if (err) {\r\n    console.log(err);\r\n  } else {\r\n    console.log(addresses);\r\n  }\r\n  console.log(\"Process time: %d seconds\", process.hrtime(startTime)[0]);\r\n});\r\n```\r\n\r\n-\r\n\r\n```\r\n$ time node dns.js\r\nevents.js:85\r\nthrow er; // Unhandled 'error' event\r\n^\r\nError: connect ECONNREFUSED\r\nat exports._errnoException (util.js:746:11)\r\nat TCPConnectWrap.afterConnect [as oncomplete] (net.js:983:19)\r\n\r\nreal    0m0.671s\r\nuser    0m0.179s\r\nsys     0m0.009s\r\n```\r\n\r\n-\r\n\r\n* expected behavior, go to next server in the array for DNS resolving\r\n* current behavior, throws an error ECONNREFUSED (doesn't return the error object)\r\n* note, in this case DNS Server 127.0.0.1 returns an ICMP Unreachable\r\n\r\n---\r\n\r\n```javascript\r\n\"use strict\";\r\n\r\nvar dns = require(\"native-dns\");\r\nvar startTime = process.hrtime();\r\n\r\ndns.platform.attempts = 10;\r\ndns.platform.cache = false;\r\ndns.platform.timeout = 500;\r\n\r\ndns.platform.name_servers = [\r\n  {address: \"1.1.1.1\", port: 53, type: \"udp\"},\r\n  {address: \"1.1.1.2\", port: 53, type: \"udp\"}\r\n];\r\n\r\ndns.resolve(\"www.google.com\", \"A\", function (err, addresses) {\r\n  if (err) {\r\n    console.log(err);\r\n  } else {\r\n    console.log(addresses);\r\n  }\r\n  console.log(\"Process time: %d seconds\", process.hrtime(startTime)[0]);\r\n});\r\n```\r\n\r\n-\r\n\r\n```\r\n$ time node dns.js\r\n{ [Error: getHostByName ETIMEOUT] errno: 'ETIMEOUT', syscall: 'getHostByName' }\r\nProcess time: 5 seconds\r\nevents.js:85\r\nthrow er; // Unhandled 'error' event\r\n^\r\nError: connect ETIMEDOUT\r\nat exports._errnoException (util.js:746:11)\r\nat TCPConnectWrap.afterConnect [as oncomplete] (net.js:983:19)\r\n\r\nreal    2m7.993s\r\nuser    0m0.223s\r\nsys     0m0.009s\r\n\r\n```\r\n-\r\n\r\n* expected behavior, 10 attempts with 500 ms timeout\r\n* current behavior, 5 attempts with 1000 ms timeout\r\n* note, all values for attempts are divided by two and all values for timeout are multiplied by two (monitored with Wireshark)\r\n\r\n-\r\n\r\n* expected behavior, after returning the error object with ETIMEOUT, continue processing\r\n* current behavior, after returning the error object, the process is locked for two minutes and then it throws an error (doesn't return the error object)\r\n* note, these are fake DNS servers and notice that the process time console logged in the script is 5 seconds (as expected), but the total execution time is more than two minutes\r\n\r\n---\r\n"}}