2016-07-26 126 views
-2

我在节点JS发现了一个怪异的行为与http://underscorejs.org/节点JS冻结和的ReferenceError发生

当我们评价一个模板函数的引用错误发生,节点JS将冻结!

实例:

实施例1:HAPPY DAY情景:

var template = "<%= test %>"; 
var compiledTemplate = _.template(template); 
var result = compiledTemplate({test:1}); 
console.log(result); 

//RESULT (both BROWSER and NODE JS): 
//1 

实施例2:编译错误情形(额外=闭合前):

var template = "<%= test =%>"; 
var compiledTemplate = _.template(template); 
var result = compiledTemplate({test:1}); 
console.log(result); 

//RESULT (both BROWSER and NODE JS): 
//uncaughtException { [SyntaxError: Unexpected token)] 

例3:评估错误情况(测试未定义):

var template = "<%= test %>"; 
var compiledTemplate = _.template(template); 
var result = compiledTemplate({no_test_defined:1}); 
console.log(result); 

//RESULT (BROWSER): 
//Uncaught ReferenceError: test is not defined 
//RESULT (NODE JS): 
//Node JS FREEZES - nothing happens, neither and error is thrown, neither the flow goes on 

有人曾经有过类似的行为吗?任何解决方案的提示?我真的需要在try/catch块中发现异常...

干杯!

奥斯卡

回答

-1

经过一些故障排除后,我终于可以找到问题所在。

当我在Webstorm DEBUGGER内部运行这个行为时(Node JS FREEZES)。当我在命令行中运行它时,我按预期工作。如果你有什么问题,我将在Webstorm问题中进行搜索。

干杯!!!!

奥斯卡