-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块中发现异常...
干杯!
奥斯卡