2016-07-26 130 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問題中進行搜索。

乾杯!!!!

奧斯卡