node-fast-download icon indicating copy to clipboard operation
node-fast-download copied to clipboard

getaddrinfo ENOTFOUND

Open treemore opened this issue 8 years ago • 2 comments

when a url can not find the right dns,it will throw a Unhandled 'error' event. like the code blow.

https://npm.runkit.com/request

var request = require('request');

try{
var rr=request.head("http://www.aldlfladl22939334345.com",function(err,response,body){
console.info(err,body)
})
//rr.on('error',(error)=>{
//console.error('errorring',error);
//})
}catch(e){
console.error('eeeeing',e.message);
}

and if you use

rr.on('error',(error)=>{
console.error('errorring',error);
})

can catch the exception.
https://github.com/request/request/issues/1318

i think may
https://github.com/zenflow/node-fast-download/blob/master/lib/FastDownload.js#L37 will be on the 'error' event.

treemore avatar Oct 15 '17 18:10 treemore

@treemore What is the issue? What would you expect to fast-download to do when a domain can't be resolved? And what does it actually do?

zenflow avatar Oct 16 '17 21:10 zenflow

hi @zenflow
expect to fast-download to do when a domain can't be resolved : emit the error event . because domain can't be resolved use request lib we cannot know there is a exception. event use try catch cannot capture this type exception. may be like this https://github.com/treemore/node-fast-download/blob/master/lib/FastDownload.js#L66

treemore avatar Oct 18 '17 14:10 treemore