흔자
article thumbnail
반응형

Node.js에서 EventEmitters는 특정 이벤트에 대해 10개 이상의 리스너가 추가되면 경고를 출력한다.

 

 


오류

node:8348) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 

16 uncaughtException listeners added to [process]. Use emitter.setMaxListeners() to increase limit

 

나의 경우 리스너가 10개를 초과하여 아래의 함수를 사용해 이벤트 등록 개수를 제한 해제하여

문제를 해결하고자 했지만 계속해서 동일한 오류가 발생했다.

# 계속해서 오류 발생
process.setMaxListeners(15);

 

 

 


해결 방법
require('events').EventEmitter.defaultMaxListeners = 15;

 

 

Reference
 

Events | Node.js v19.4.0 Documentation

Events# Source Code: lib/events.js Much of the Node.js core API is built around an idiomatic asynchronous event-driven architecture in which certain kinds of objects (called "emitters") emit named events that cause Function objects ("listeners") to be call

nodejs.org

 

반응형
profile

흔자

@heun_n

즐겁게 개발하고 싶은 사람입니다.