From a0408fcf70615abd3e60370f7970232537881142 Mon Sep 17 00:00:00 2001 From: Szymon Marczak <36894700+szmarczak@users.noreply.github.com> Date: Wed, 11 Nov 2020 22:22:41 +0100 Subject: [PATCH 1/3] dns: add a cancel() method to the promise Resolver --- doc/api/dns.md | 8 +++ lib/internal/dns/promises.js | 1 + .../test-dns-channel-cancel-promise.js | 71 +++++++++++++++++++ test/parallel/test-dns-channel-cancel.js | 46 +++++++++--- 4 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 test/parallel/test-dns-channel-cancel-promise.js diff --git a/doc/api/dns.md b/doc/api/dns.md index a284c9d0c57bd5..90774abc0919ef 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -730,6 +730,14 @@ The following methods from the `dnsPromises` API are available: * [`resolver.reverse()`][`dnsPromises.reverse()`] * [`resolver.setServers()`][`dnsPromises.setServers()`] +### `resolver.cancel()` + + +Cancel all outstanding DNS queries made by this resolver. The corresponding +promises will be rejected with an error with code `ECANCELLED`. + ### `dnsPromises.getServers()`