Skip to content

DNS resolver cancel does not return ECANCELLED #14814

Closed
@JorgenPhi

Description

@JorgenPhi
  • Version: v8.3.0
  • Platform: Windows 10 Pro 1703 x64
  • Subsystem: dns

Hey! I am testing out the resolver.cancel method, and I am getting back ENOTFOUND instead of ECANCELLED.

Here's my script:

const { Resolver } = require('dns');
const resolver = new Resolver();
resolver.setServers([
  '123.45.67.89' // Not a real DNS Server
]);


function reverseLookup(ip) {
	// Variable to test if we got our answer back in time
	var matchfound = false;
	resolver.reverse(ip,function(err,domains){
		if(err) {
			// View our error
			console.error(err);
		} else {
			var matchfound = true;
			// Found a match, or two.
			domains.forEach(function(domain){
				console.log(domain);
			});
		}
	});
	setTimeout(function() {
		if(matchfound === false) {
			console.error("Took too long to reverse IP. Cancelling lookup.")
			resolver.cancel();
		}
	}, 1); // Set to 1 for testing
}

reverseLookup('8.8.8.8'); // google-public-dns-a.google.com

Output:

PS C:\Users\Jorgen\Documents\app_backend\tools> node .\dns-reverse-lookup.js
Took too long to reverse IP. Cancelling lookup.
{ Error: getHostByAddr ENOTFOUND 8.8.8.8
    at errnoException (dns.js:53:10)
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:239:19)
  code: 'ENOTFOUND',
  errno: 'ENOTFOUND',
  syscall: 'getHostByAddr',
  hostname: '8.8.8.8' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    caresIssues and PRs related to the c-ares dependency or the cares_wrap binding.dnsIssues and PRs related to the dns subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions