diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-09-19 06:38:37 +0200 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-09-20 09:39:14 -0700 |
commit | 03738183c74d0be43846f96562cb89dce929a953 (patch) | |
tree | 2a88dc34872d54def1b7aa5220d0bed157a65626 /lib/dns.js | |
parent | a0f79867dcc4e58e0753af0644759025ad6e9749 (diff) | |
download | node-new-03738183c74d0be43846f96562cb89dce929a953.tar.gz |
dns: fix c-ares error reporting regression
The test case from the previous commit exposed a regression in the way
that c-ares errors are reported to JS land. Said regression was
introduced in commit 756b622 ("src: add multi-context support").
Fixes the following test failure:
$ out/Release/node test/simple/test-dns-regress-6244
util.js:675
var errname = uv.errname(err);
^
Error: err >= 0
at Object.exports._errnoException (util.js:675:20)
at errnoException (dns.js:43:15)
at Object.onresolve [as oncomplete] (dns.js:145:19)
lib/dns.js erroneously assumed that the error code was a libuv error
code when it's really a c-ares status code. Libuv handles getaddrinfo()
style lookups (which is by far the most common type of lookup), that's
why this bug wasn't discovered earlier.
Diffstat (limited to 'lib/dns.js')
-rw-r--r-- | lib/dns.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/dns.js b/lib/dns.js index dd274825b2..3e4b90f6e3 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -34,9 +34,12 @@ function errnoException(err, syscall) { if (err === uv.UV_EAI_MEMORY || err === uv.UV_EAI_NODATA || err === uv.UV_EAI_NONAME) { - var ex = new Error(syscall + ' ENOTFOUND'); - ex.code = 'ENOTFOUND'; - ex.errno = 'ENOTFOUND'; + err = 'ENOTFOUND'; + } + if (typeof err === 'string') { // c-ares error code. + var ex = new Error(syscall + ' ' + err); + ex.code = err; + ex.errno = err; ex.syscall = syscall; return ex; } |