Winston - MaxListenersExceededWarning: обнаружена возможная утечка памяти EventEmitter - PullRequest
0 голосов
/ 01 ноября 2019

Ошибка ниже в winston при использовании ведения журнала файлов с пакетом winston-daily-rotate-file, код хорошо работает при ведении журнала консоли winston,

  MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
        at _addListener (events.js:256:17)
        at DailyRotateFile.addListener (events.js:272:10)
        at DailyRotateFile.once (events.js:301:8)
        at asyncForEach (/home/ubuntumachine/Desktop/project/node_modules/winston/lib/winston/exception-handler.js:217:17)
        at /home/ubuntumachine/Desktop/project/node_modules/async/internal/withoutIndex.js:9:16
        at eachOfArrayLike (/home/ubuntumachine/Desktop/project/node_modules/async/eachOf.js:65:9)
        at exports.default (/home/ubuntumachine/Desktop/project/node_modules/async/eachOf.js:9:5)
        at eachLimit (/home/ubuntumachine/Desktop/project/node_modules/async/forEach.js:80:24)
        at ExceptionHandler._uncaughtException (/home/ubuntumachine/Desktop/project/node_modules/winston/lib/winston/exception-handler.js:203:5)
        at process.emit (events.js:198:13)
    (node:20805) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 finish listeners added. Use emitter.setMaxListeners() to increase limit
        at _addListener (events.js:256:17)
        at DailyRotateFile.addListener (events.js:272:10)
        at DailyRotateFile.once (events.js:301:8)
        at asyncForEach (/home/ubuntumachine/Desktop/project/node_modules/winston/lib/winston/exception-handler.js:216:17)
        at /home/ubuntumachine/Desktop/project/node_modules/async/internal/withoutIndex.js:9:16
        at eachOfArrayLike (/home/ubuntumachine/Desktop/project/node_modules/async/eachOf.js:65:9)
        at exports.default (/home/ubuntumachine/Desktop/project/node_modules/async/eachOf.js:9:5)
        at eachLimit (/home/ubuntumachine/Desktop/project/node_modules/async/forEach.js:80:24)
        at ExceptionHandler._uncaughtException (/home/ubuntumachine/Desktop/project/node_modules/winston/lib/winston/exception-handler.js:203:5)
        at process.emit (events.js:198:13)
    (node:20805) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 31 error listeners added. Use emitter.setMaxListeners() to increase limit
        at _addListener (events.js:256:17)
        at Console.addListener (events.js:272:10)
        at Console.once (events.js:301:8)
        at asyncForEach (/home/ubuntumachine/Desktop/project/node_modules/winston/lib/winston/exception-handler.js:217:17)
        at /home/ubuntumachine/Desktop/project/node_modules/async/internal/withoutIndex.js:9:16
        at eachOfArrayLike (/home/ubuntumachine/Desktop/project/node_modules/async/eachOf.js:65:9)
        at exports.default (/home/ubuntumachine/Desktop/project/node_modules/async/eachOf.js:9:5)
        at eachLimit (/home/ubuntumachine/Desktop/project/node_modules/async/forEach.js:80:24)
        at ExceptionHandler._uncaughtException (/home/ubuntumachine/Desktop/project/node_modules/winston/lib/winston/exception-handler.js:203:5)
        at process.emit (events.js:198:13)

Пытался установить максимальное число слушателей на бесконечность,

const EventEmitter = require('events');
const emitter = new EventEmitter();
emitter.setMaxListeners(Infinity);

все еще сталкивается с той же проблемой.

...