Nodejs reads the remote address for some reasons

  node.js, question
var request = nodeRequire("request");
 
 Dlog ('Tag 1');
 request.head(src, function(err, res_req, body){
 Dlog ('Mark2');
 
 }).on('error', function(err) {
 Dlog ('Mark3');
 console.log(err)
 });

Mark 1 is output 230 times, mark 2 is output 202 times, mark 3 is 0 times, which means that some are lost, what is the most likely reason.

……
request.head(src, function(err, res_req, body){
……
}).on(‘error’, function(err) {

Don’t you think it’s strange for the title owner, why are there ERRs in the parameters inside of the two places, and what’s the difference between the two ERRs? Where on earth should we deal with the mistake?

So the subject should have a good lookDocument, there are two kinds of writing can choose:

var request = nodeRequire("request");
 
 Dlog ('Tag 1');
 request.head(src, function(err, res_req, body){
 if (err) {
 Dlog ('Mark3');
 return;
 bracket
 Dlog ('Mark2');
 })

Or ..

var request = nodeRequire("request");
 Dlog ('Tag 1');
 request.head(src)
 .on('response', function (res) {
 Dlog ('Mark2');
 })
 .on('error', function (err) {
 Dlog ('Mark3');
 });