From 732658e4cf0ab676040cdbad92f39b93fbacaa80 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 27 Jul 2017 19:03:11 +0200 Subject: [PATCH] dns: add channel.cancel() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can be used to implement custom timeouts. Fixes: https://github.com/nodejs/node/issues/7231 PR-URL: https://github.com/nodejs/node/pull/14518 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Tobias Nießen --- doc/api/dns.md | 8 +++++++ lib/dns.js | 4 ++++ src/cares_wrap.cc | 8 +++++++ test/parallel/test-dns-channel-cancel.js | 29 ++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 test/parallel/test-dns-channel-cancel.js diff --git a/doc/api/dns.md b/doc/api/dns.md index e9de95c118c573..5be30f22284b9c 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -95,6 +95,14 @@ The following methods from the `dns` module are available: * [`resolver.resolveTxt()`][`dns.resolveTxt()`] * [`resolver.reverse()`][`dns.reverse()`] +### resolver.cancel() + + +Cancel all outstanding DNS queries made by this resolver. The corresponding +callbacks will be called with an error with code `ECANCELLED`. + ## dns.getServers()