diff --git a/lib/dns.js b/lib/dns.js index bdcd14a5c6bb32..f6b3b191fc438d 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -230,7 +230,8 @@ function resolver(bindingName) { req.hostname = name; req.oncomplete = onresolve; var err = binding(req, name); - if (err) throw errnoException(err, bindingName); + if (err) + return callback(errnoException(err, bindingName)); callback.immediately = true; return req; }; diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index abc7edbf598097..51cc2596770f38 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -90,6 +90,11 @@ assert.doesNotThrow(function() { dns.lookup(NaN, noop); }); +// Make sure that dns.reverse does not throw if ip is invalid +assert.doesNotThrow(function() { + dns.reverse('foo', noop) +}); + /* * Make sure that dns.lookup throws if hints does not represent a valid flag. * (dns.V4MAPPED | dns.ADDRCONFIG) + 1 is invalid because: