![](/img/trans.png)
[英]How do I troubleshoot an Javascript Office Addin (OneNote) created using Node.js and Yeoman?
[英]How do I troubleshoot MaxListenersExceededWarning messages from Node?
我正在通過Mocha(通過Node)運行Selenium測試,每次我進行全部測試時,都會在同一確切位置看到此警告消息:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added. Use emitter.setMaxListeners() to increase limit
我沒有看到這個問題,如果我運行一個測試,所以這個問題似乎與運行多個測試。
我嘗試指定--trace-warnings
命令行參數,但是它似乎沒有任何作用。 具體來說,我修改了我的測試運行器腳本來做到這一點:
node --trace-warnings node_modules/mocha/bin/mocha ...
我仍然看到相同的警告消息,但是沒有看到堆棧跟蹤。
SO上的其他帖子提供了增加限制的建議,但這不是我要在此處執行的操作。 我試圖弄清楚為什么此警告首先出現。
我不知道為什么命令行參數不起作用,但是我找到了另一種方法來從此處獲取堆棧跟蹤:
https://nodejs.org/docs/latest/api/process.html#process_event_warning
process.on('warning', (warning) => {
console.warn(warning.name); // Print the warning name
console.warn(warning.message); // Print the warning message
console.warn(warning.stack); // Print the stack trace
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.