반응형
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
반응형
'Develop > Node.js' 카테고리의 다른 글
[Node.js] MariaDB 연결을 위한 간단한 모듈 작성 방법 (0) | 2023.05.02 |
---|---|
[Node.js] npm install 옵션 --save와 --save-dev의 차이점 (0) | 2023.02.08 |
[Node.js] 백그라운드 실행과 모니터링 패키지 pm2 설치하기 - 2 (0) | 2023.01.13 |
[Node.js] 백그라운드 실행과 모니터링 패키지 pm2 설치하기 - 1 (0) | 2023.01.13 |