gotwarlost / istanbul

Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests and browser tests. Built for scale.
Other
8.7k stars 787 forks source link

possible bug #720

Closed ORESoftware closed 7 years ago

ORESoftware commented 7 years ago

This is a weird one, been trying to debug it for awhile, used the new node --inspect feature. I put a debugger; statement at the very very top of my file (the entry point file), and I can't reach that debugger statement, so seems to happen in the Istanbul instrumentation code.

This problem is happening for both Node version 6.2.2 and version 7.0.0.

First the error:

 => Uncaught exception => 
 SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.<anonymous> (/Users/Olegzandr/WebstormProjects/oresoftware/suman/lib/run-child.js:9:2930)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions.(anonymous function) [as .js] (/Users/Olegzandr/WebstormProjects/oresoftware/suman/node_modules/istanbul/lib/hook.js:107:24)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Function.Module.runMain (module.js:607:10)
    at runFn (/Users/Olegzandr/WebstormProjects/oresoftware/suman/node_modules/istanbul/lib/command/common/run-with-cover.js:122:16)
    at /Users/Olegzandr/WebstormProjects/oresoftware/suman/node_modules/istanbul/lib/command/common/run-with-cover.js:251:17

it seems to happen in this file:

screenshot 2016-11-07 23 09 36

here is the contents of that file:


(function (exports, require, module, __filename, __dirname) { 
var __cov_8sDTk4RoFbVuGau5FurrZg = (Function('return this'))();
if (!__cov_8sDTk4RoFbVuGau5FurrZg.$$cov_1478588955686$$) { __cov_8sDTk4RoFbVuGau5FurrZg.$$cov_1478588955686$$ = {}; }
__cov_8sDTk4RoFbVuGau5FurrZg = __cov_8sDTk4RoFbVuGau5FurrZg.$$cov_1478588955686$$;
if (!(__cov_8sDTk4RoFbVuGau5FurrZg['/Users/Olegzandr/WebstormProjects/oresoftware/suman/lib/run-child.js'])) {
   __cov_8sDTk4RoFbVuGau5FurrZg['/Users/Olegzandr/WebstormProjects/oresoftware/suman/lib/run-child.js'] = {"path":"/Users/Olegzandr/WebstormProjects/oresoftware/suman/lib/run-child.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0},"fnMap":{"1":{"name":"(anonymous_1)","line":16,"loc":{"start":{"line":16,"column":31},"end":{"line":16,"column":45}}},"2":{"name":"(anonymous_2)","line":20,"loc":{"start":{"line":20,"column":32},"end":{"line":20,"column":47}}},"3":{"name":"(anonymous_3)","line":91,"loc":{"start":{"line":91,"column":16},"end":{"line":91,"column":31}}},"4":{"name":"(anonymous_4)","line":114,"loc":{"start":{"line":114,"column":10},"end":{"line":114,"column":22}}},"5":{"name":"(anonymous_5)","line":121,"loc":{"start":{"line":121,"column":10},"end":{"line":121,"column":22}}},"6":{"name":"(anonymous_6)","line":122,"loc":{"start":{"line":122,"column":25},"end":{"line":122,"column":37}}}},"statementMap":{"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":29}},"2":{"start":{"line":3,"column":0},"end":{"line":3,"column":29}},"3":{"start":{"line":6,"column":0},"end":{"line":6,"column":38}},"4":{"start":{"line":9,"column":0},"end":{"line":9,"column":55}},"5":{"start":{"line":10,"column":0},"end":{"line":10,"column":48}},"6":{"start":{"line":12,"column":0},"end":{"line":12,"column":46}},"7":{"start":{"line":13,"column":0},"end":{"line":13,"column":76}},"8":{"start":{"line":16,"column":0},"end":{"line":18,"column":4}},"9":{"start":{"line":17,"column":9},"end":{"line":17,"column":102}},"10":{"start":{"line":20,"column":0},"end":{"line":48,"column":3}},"11":{"start":{"line":22,"column":4},"end":{"line":35,"column":5}},"12":{"start":{"line":23,"column":8},"end":{"line":30,"column":11}},"13":{"start":{"line":33,"column":8},"end":{"line":34,"column":99}},"14":{"start":{"line":38,"column":4},"end":{"line":38,"column":102}},"15":{"start":{"line":40,"column":4},"end":{"line":43,"column":5}},"16":{"start":{"line":41,"column":8},"end":{"line":42,"column":44}},"17":{"start":{"line":51,"column":0},"end":{"line":51,"column":9}},"18":{"start":{"line":54,"column":0},"end":{"line":54,"column":57}},"19":{"start":{"line":55,"column":0},"end":{"line":55,"column":51}},"20":{"start":{"line":56,"column":0},"end":{"line":56,"column":78}},"21":{"start":{"line":57,"column":0},"end":{"line":58,"column":101}},"22":{"start":{"line":62,"column":0},"end":{"line":62,"column":95}},"23":{"start":{"line":64,"column":0},"end":{"line":73,"column":1}},"24":{"start":{"line":66,"column":4},"end":{"line":66,"column":72}},"25":{"start":{"line":68,"column":4},"end":{"line":72,"column":7}},"26":{"start":{"line":76,"column":0},"end":{"line":80,"column":1}},"27":{"start":{"line":77,"column":4},"end":{"line":79,"column":7}},"28":{"start":{"line":84,"column":0},"end":{"line":84,"column":62}},"29":{"start":{"line":88,"column":0},"end":{"line":88,"column":33}},"30":{"start":{"line":89,"column":0},"end":{"line":89,"column":26}},"31":{"start":{"line":91,"column":0},"end":{"line":103,"column":3}},"32":{"start":{"line":93,"column":4},"end":{"line":99,"column":7}},"33":{"start":{"line":101,"column":4},"end":{"line":101,"column":29}},"34":{"start":{"line":102,"column":4},"end":{"line":102,"column":76}},"35":{"start":{"line":106,"column":0},"end":{"line":111,"column":1}},"36":{"start":{"line":107,"column":4},"end":{"line":107,"column":68}},"37":{"start":{"line":110,"column":4},"end":{"line":110,"column":108}},"38":{"start":{"line":113,"column":0},"end":{"line":127,"column":1}},"39":{"start":{"line":114,"column":4},"end":{"line":116,"column":7}},"40":{"start":{"line":115,"column":8},"end":{"line":115,"column":92}},"41":{"start":{"line":119,"column":4},"end":{"line":119,"column":42}},"42":{"start":{"line":121,"column":4},"end":{"line":126,"column":7}},"43":{"start":{"line":122,"column":8},"end":{"line":125,"column":11}},"44":{"start":{"line":123,"column":12},"end":{"line":123,"column":60}},"45":{"start":{"line":124,"column":12},"end":{"line":124,"column":30}}},"branchMap":{"1":{"line":16,"type":"binary-expr","locations":[{"start":{"line":16,"column":15},"end":{"line":16,"column":27}},{"start":{"line":16,"column":31},"end":{"line":18,"column":3}}]},"2":{"line":22,"type":"if","locations":[{"start":{"line":22,"column":4},"end":{"line":22,"column":4}},{"start":{"line":22,"column":4},"end":{"line":22,"column":4}}]},"3":{"line":28,"type":"binary-expr","locations":[{"start":{"line":28,"column":23},"end":{"line":28,"column":32}},{"start":{"line":28,"column":36},"end":{"line":28,"column":39}}]},"4":{"line":38,"type":"binary-expr","locations":[{"start":{"line":38,"column":74},"end":{"line":38,"column":83}},{"start":{"line":38,"column":87},"end":{"line":38,"column":90}}]},"5":{"line":40,"type":"if","locations":[{"start":{"line":40,"column":4},"end":{"line":40,"column":4}},{"start":{"line":40,"column":4},"end":{"line":40,"column":4}}]},"6":{"line":40,"type":"binary-expr","locations":[{"start":{"line":40,"column":8},"end":{"line":40,"column":61}},{"start":{"line":40,"column":65},"end":{"line":40,"column":81}},{"start":{"line":40,"column":85},"end":{"line":40,"column":111}}]},"7":{"line":40,"type":"binary-expr","locations":[{"start":{"line":40,"column":15},"end":{"line":40,"column":24}},{"start":{"line":40,"column":28},"end":{"line":40,"column":31}}]},"8":{"line":58,"type":"binary-expr","locations":[{"start":{"line":58,"column":4},"end":{"line":58,"column":29}},{"start":{"line":58,"column":33},"end":{"line":58,"column":100}}]},"9":{"line":58,"type":"binary-expr","locations":[{"start":{"line":58,"column":60},"end":{"line":58,"column":87}},{"start":{"line":58,"column":91},"end":{"line":58,"column":98}}]},"10":{"line":64,"type":"if","locations":[{"start":{"line":64,"column":0},"end":{"line":64,"column":0}},{"start":{"line":64,"column":0},"end":{"line":64,"column":0}}]},"11":{"line":76,"type":"if","locations":[{"start":{"line":76,"column":0},"end":{"line":76,"column":0}},{"start":{"line":76,"column":0},"end":{"line":76,"column":0}}]},"12":{"line":113,"type":"if","locations":[{"start":{"line":113,"column":0},"end":{"line":113,"column":0}},{"start":{"line":113,"column":0},"end":{"line":113,"column":0}}]}}};
}
__cov_8sDTk4RoFbVuGau5FurrZg = __cov_8sDTk4RoFbVuGau5FurrZg['/Users/Olegzandr/WebstormProjects/oresoftware/suman/lib/run-child.js'];
__cov_8sDTk4RoFbVuGau5FurrZg.s['1']++;const path=require('path');__cov_8sDTk4RoFbVuGau5FurrZg.s['2']++;const util=require('util');__cov_8sDTk4RoFbVuGau5FurrZg.s['3']++;const colors=require('colors/safe');__cov_8sDTk4RoFbVuGau5FurrZg.s['4']++;const constants=require('../config/suman-constants');__cov_8sDTk4RoFbVuGau5FurrZg.s['5']++;const sumanUtils=require('suman-utils/utils');__cov_8sDTk4RoFbVuGau5FurrZg.s['6']++;const usingRunner=global.usingRunner=true;__cov_8sDTk4RoFbVuGau5FurrZg.s['7']++;const root=global.projectRoot=sumanUtils.findProjectRoot(process.cwd());__cov_8sDTk4RoFbVuGau5FurrZg.s['8']++;process.send=(__cov_8sDTk4RoFbVuGau5FurrZg.b['1'][0]++,process.send)||(__cov_8sDTk4RoFbVuGau5FurrZg.b['1'][1]++,function(data){__cov_8sDTk4RoFbVuGau5FurrZg.f['1']++;__cov_8sDTk4RoFbVuGau5FurrZg.s['9']++;console.log(' => Runner cannot receive data, so logging it here => \n'+util.inspect(data));});__cov_8sDTk4RoFbVuGau5FurrZg.s['10']++;process.on('uncaughtException',function(err){__cov_8sDTk4RoFbVuGau5FurrZg.f['2']++;__cov_8sDTk4RoFbVuGau5FurrZg.s['11']++;if(typeof process.send==='function'){__cov_8sDTk4RoFbVuGau5FurrZg.b['2'][0]++;__cov_8sDTk4RoFbVuGau5FurrZg.s['12']++;process.send({type:constants.runner_message_type.FATAL,data:{msg:' => Suman => fatal error in suite with path="'+filePath+'"'+'\n (note: You will need to transpile your test files if you wish to use ES7 features)',error:(__cov_8sDTk4RoFbVuGau5FurrZg.b['3'][0]++,err.stack)||(__cov_8sDTk4RoFbVuGau5FurrZg.b['3'][1]++,err)}});}else{__cov_8sDTk4RoFbVuGau5FurrZg.b['2'][1]++;__cov_8sDTk4RoFbVuGau5FurrZg.s['13']++;console.error(new Error(' => Suman implementation warning => process.send is '+'not a function even though we are using runner. Perhaps we are using Istanbul?').stack);}__cov_8sDTk4RoFbVuGau5FurrZg.s['14']++;console.log(' => Suman => Uncaught exception in your test =>','\n',((__cov_8sDTk4RoFbVuGau5FurrZg.b['4'][0]++,err.stack)||(__cov_8sDTk4RoFbVuGau5FurrZg.b['4'][1]++,err))+'\n\n');__cov_8sDTk4RoFbVuGau5FurrZg.s['15']++;if((__cov_8sDTk4RoFbVuGau5FurrZg.b['6'][0]++,String((__cov_8sDTk4RoFbVuGau5FurrZg.b['7'][0]++,err.stack)||(__cov_8sDTk4RoFbVuGau5FurrZg.b['7'][1]++,err)).match(/Cannot find module/i))&&(__cov_8sDTk4RoFbVuGau5FurrZg.b['6'][1]++,global.sumanOpts)&&(__cov_8sDTk4RoFbVuGau5FurrZg.b['6'][2]++,global.sumanOpts.transpile)){__cov_8sDTk4RoFbVuGau5FurrZg.b['5'][0]++;__cov_8sDTk4RoFbVuGau5FurrZg.s['16']++;console.log(' => If transpiling, you may need to transpile your entire test directory to the target directory using the '+'--transpile options together.');}else{__cov_8sDTk4RoFbVuGau5FurrZg.b['5'][1]++;}});__cov_8sDTk4RoFbVuGau5FurrZg.s['17']++;debugger;__cov_8sDTk4RoFbVuGau5FurrZg.s['18']++;const babelarg=process.argv.indexOf('--register')>-1;__cov_8sDTk4RoFbVuGau5FurrZg.s['19']++;const filePath=process.env.SUMAN_CHILD_TEST_PATH;__cov_8sDTk4RoFbVuGau5FurrZg.s['20']++;const sumanConfig=global.sumanConfig=JSON.parse(process.env.SUMAN_CONFIG);__cov_8sDTk4RoFbVuGau5FurrZg.s['21']++;const sumanHelperDirRoot=global.sumanHelperDirRoot=(__cov_8sDTk4RoFbVuGau5FurrZg.b['8'][0]++,global.sumanHelperDirRoot)||(__cov_8sDTk4RoFbVuGau5FurrZg.b['8'][1]++,path.resolve(root+'/'+((__cov_8sDTk4RoFbVuGau5FurrZg.b['9'][0]++,sumanConfig.sumanHelpersDir)||(__cov_8sDTk4RoFbVuGau5FurrZg.b['9'][1]++,'suman'))));__cov_8sDTk4RoFbVuGau5FurrZg.s['22']++;const register=global.useBabelRegister=process.argv.indexOf('--use-babel-register')>-1;__cov_8sDTk4RoFbVuGau5FurrZg.s['23']++;if(register){__cov_8sDTk4RoFbVuGau5FurrZg.b['10'][0]++;__cov_8sDTk4RoFbVuGau5FurrZg.s['24']++;console.log(colors.bgRed.white(' => We are using babel-register.'));__cov_8sDTk4RoFbVuGau5FurrZg.s['25']++;require('babel-register')({});}else{__cov_8sDTk4RoFbVuGau5FurrZg.b['10'][1]++;}__cov_8sDTk4RoFbVuGau5FurrZg.s['26']++;if(babelarg){__cov_8sDTk4RoFbVuGau5FurrZg.b['11'][0]++;__cov_8sDTk4RoFbVuGau5FurrZg.s['27']++;require('babel-core/register')({ignore:/node_modules/});}else{__cov_8sDTk4RoFbVuGau5FurrZg.b['11'][1]++;}__cov_8sDTk4RoFbVuGau5FurrZg.s['28']++;const singleProc=process.env.SUMAN_SINGLE_PROCESS==='yes';__cov_8sDTk4RoFbVuGau5FurrZg.s['29']++;const domain=require('domain');__cov_8sDTk4RoFbVuGau5FurrZg.s['30']++;const d=domain.create();__cov_8sDTk4RoFbVuGau5FurrZg.s['31']++;d.once('error',function(err){__cov_8sDTk4RoFbVuGau5FurrZg.f['3']++;__cov_8sDTk4RoFbVuGau5FurrZg.s['32']++;process.send({type:constants.runner_message_type.FATAL,data:{msg:' => Suman => fatal error in suite with path="'+filePath+'"',error:err.stack}});__cov_8sDTk4RoFbVuGau5FurrZg.s['33']++;console.error(err.stack);__cov_8sDTk4RoFbVuGau5FurrZg.s['34']++;process.exit(constants.EXIT_CODES.UNEXPECTED_FATAL_ERROR_DOMAIN_CAUGHT);});__cov_8sDTk4RoFbVuGau5FurrZg.s['35']++;try{__cov_8sDTk4RoFbVuGau5FurrZg.s['36']++;require(path.resolve(sumanHelperDirRoot+'/suman.globals.js'));}catch(err){__cov_8sDTk4RoFbVuGau5FurrZg.s['37']++;console.error(' => Suman usage warning => Could not load your suman.globals.js file => \n'+err.stack);}__cov_8sDTk4RoFbVuGau5FurrZg.s['38']++;if(singleProc){__cov_8sDTk4RoFbVuGau5FurrZg.b['12'][0]++;__cov_8sDTk4RoFbVuGau5FurrZg.s['39']++;d.run(function(){__cov_8sDTk4RoFbVuGau5FurrZg.f['4']++;__cov_8sDTk4RoFbVuGau5FurrZg.s['40']++;require('./handle-single-proc')(JSON.parse(process.env.SUMAN_SINGLE_PROCESS_FILES));});}else{__cov_8sDTk4RoFbVuGau5FurrZg.b['12'][1]++;__cov_8sDTk4RoFbVuGau5FurrZg.s['41']++;console.log('About to run domain...');__cov_8sDTk4RoFbVuGau5FurrZg.s['42']++;d.run(function(){__cov_8sDTk4RoFbVuGau5FurrZg.f['5']++;__cov_8sDTk4RoFbVuGau5FurrZg.s['43']++;process.nextTick(function(){__cov_8sDTk4RoFbVuGau5FurrZg.f['6']++;__cov_8sDTk4RoFbVuGau5FurrZg.s['44']++;console.log('Requring filepath => '+filePath);__cov_8sDTk4RoFbVuGau5FurrZg.s['45']++;require(filePath);});});}

});

not sure what's happening, seems like internal error?

ORESoftware commented 7 years ago

nevermine, appears to be my code :)