一尘不染

检测到可能的EventEmitter内存泄漏

node.js

我收到以下警告:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace: 
    at EventEmitter.<anonymous> (events.js:139:15)
    at EventEmitter.<anonymous> (node.js:385:29)
    at Server.<anonymous> (server.js:20:17)
    at Server.emit (events.js:70:17)
    at HTTPParser.onIncoming (http.js:1514:12)
    at HTTPParser.onHeadersComplete (http.js:102:31)
    at Socket.ondata (http.js:1410:22)
    at TCP.onread (net.js:354:27)

我在server.js中编写了这样的代码:

http.createServer(
    function (req, res) { ... }).listen(3013);

如何解决呢?


阅读 378

收藏
2020-07-07

共1个答案

一尘不染

这是在解释节点eventEmitter文档

这是哪个版本的Node?您还有什么其他代码?那不是正常行为。

简而言之,其: process.setMaxListeners(0);

2020-07-07