本文介绍了(节点:125008)MaxListenersExceededWarning:检测到可能的EventEmitter内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! (节点:125008)MaxListenersExceededWarning:检测到可能的EventEmitter内存泄漏。添加了11个就绪的侦听器。使用generator.setMaxListeners()增加限制我到底如何增加侦听器事件的数量?我四处搜寻,但尝试过的方法均无效:(How exactly do I increase the number of listener events? I've searched around and none of the methods I've tried have worked : (推荐答案在手册中对此进行了解释: http://nodejs.org/docs/latest/api/events.html# events_emitter_setmaxlisteners_nThis is explained in the manual: http://nodejs.org/docs/latest/api/events.html#events_emitter_setmaxlisteners_n这是什么版本的Node?您还拥有其他什么代码?这不是正常行为。What version of Node is this? What other code do you have? That isn't normal behavior.简而言之,它是: process.setMaxListeners(0);另请参见: node.js-请求-如何 emitter.setMaxListeners()?我想在此指出警告是有原因的,正确的解决办法很可能不是增加限制,而是找出原因在同一个事件中添加了这么多的侦听器。仅当您知道为什么有这么多的侦听器时才增加限制I'd like to point out here that that warning is there for a reason and there's a good chance the right fix is not increasing the limit but figuring out why you're adding so many listeners to the same event. Only increase the limit if you know why so many listeners are being added and are confident it's what you really want.我找到此页面是因为收到此警告,而我使用的某些代码中存在错误那把全局对象变成了EventEmitter!我当然建议不要在全球范围内增加限额,因为您不希望这些事情被忽视。I found this page because I got this warning and in my case there was a bug in some code I was using that was turning the global object into an EventEmitter! I'd certainly advise against increasing the limit globally because you don't want these things to go unnoticed. 这篇关于(节点:125008)MaxListenersExceededWarning:检测到可能的EventEmitter内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-16 01:53