From d4442b15bfd833dd3efab22d2d02978afba1f793 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 19 May 2020 22:39:58 +0200 Subject: [PATCH] dns: make dns.Resolver timeout configurable PR-URL: https://github.com/nodejs/node/pull/33472 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Jiawen Geng --- doc/api/dns.md | 16 +++++++ lib/internal/dns/promises.js | 6 ++- lib/internal/dns/utils.js | 13 +++++- src/cares_wrap.cc | 26 +++++++---- test/parallel/test-dns-channel-timeout.js | 53 +++++++++++++++++++++++ 5 files changed, 101 insertions(+), 13 deletions(-) create mode 100644 test/parallel/test-dns-channel-timeout.js diff --git a/doc/api/dns.md b/doc/api/dns.md index ff318016d4becb..a5b3b82ea12b41 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -92,6 +92,22 @@ The following methods from the `dns` module are available: * [`resolver.reverse()`][`dns.reverse()`] * [`resolver.setServers()`][`dns.setServers()`] +### `Resolver([options])` + + +Create a new resolver. + +* `options` {Object} + * `timeout` {integer} Query timeout in milliseconds, or `-1` to use the + default timeout. + ### `resolver.cancel()`