Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaking listeners when 'handleExceptions: true' and 'exitOnError: false' #218

Closed
jrgm opened this issue Jan 18, 2013 · 8 comments
Closed

Comments

@jrgm
Copy link

jrgm commented Jan 18, 2013

Happens with either 0.6.2 or master.

Test program:

    var winston = require('winston');

    var logger = new winston.Logger({
      transports: [
        new winston.transports.File({
          filename: '/tmp/winston.log',
          handleExceptions: true
        })
      ],
      exitOnError: false
    });

    var interval = setInterval(function() {
      throw new Error('oops');
    }, 1000);

    process.on('SIGINT', function() {
      clearInterval(interval);
    });

Output:

    $ node leak.js
    (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
    Trace
        at EventEmitter.addListener (events.js:175:15)
        at EventEmitter.once (events.js:196:8)
        at Transport.logException (/Users/jmorrison/github/winston-bug/node_modules/winston/lib/winston/transports/transport.js:118:8)
        at logAndWait (/Users/jmorrison/github/winston-bug/node_modules/winston/lib/winston/logger.js:613:15)
        at async.forEach (/Users/jmorrison/github/winston-bug/node_modules/winston/node_modules/async/lib/async.js:86:13)
        at Array.forEach (native)
        at _forEach (/Users/jmorrison/github/winston-bug/node_modules/winston/node_modules/async/lib/async.js:26:24)
        at Object.async.forEach (/Users/jmorrison/github/winston-bug/node_modules/winston/node_modules/async/lib/async.js:85:9)
        at Logger._uncaughtException (/Users/jmorrison/github/winston-bug/node_modules/winston/lib/winston/logger.js:636:9)
        at process.EventEmitter.emit (events.js:126:20)
    (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
    Trace
        at EventEmitter.addListener (events.js:175:15)
        at EventEmitter.once (events.js:196:8)
        at Transport.logException (/Users/jmorrison/github/winston-bug/node_modules/winston/lib/winston/transports/transport.js:117:8)
        at logAndWait (/Users/jmorrison/github/winston-bug/node_modules/winston/lib/winston/logger.js:613:15)
        at async.forEach (/Users/jmorrison/github/winston-bug/node_modules/winston/node_modules/async/lib/async.js:86:13)
        at Array.forEach (native)
        at _forEach (/Users/jmorrison/github/winston-bug/node_modules/winston/node_modules/async/lib/async.js:26:24)
        at Object.async.forEach (/Users/jmorrison/github/winston-bug/node_modules/winston/node_modules/async/lib/async.js:85:9)
        at Logger._uncaughtException (/Users/jmorrison/github/winston-bug/node_modules/winston/lib/winston/logger.js:636:9)
        at process.EventEmitter.emit (events.js:126:20)
@jrgm
Copy link
Author

jrgm commented Jan 19, 2013

Sorry, should have added: node 0.8.17

@igoramadas
Copy link

Any updates on this? I'm having the same problem here :-(

@pccowboy
Copy link

FWIW, the same error happens with exitOnError = true, node 0.8.15. I am going to take a quick look under the hood, but IANAE.

@pccowboy
Copy link

In my case, it seems this is due to debug logging throwing stuff to the console faster than the one-time event listeners get collected. It seems to happen intermittently in my case.

Perhaps if a transport is set to 'debug' winston could increase the listeners to try and prevent this, but I suspect that it is very dependent upon the latency of the transport and how hard your application is crunching CPU.

Hope this helps a bit.

@mainiak
Copy link

mainiak commented May 31, 2013

See also issue #213. I am having this issue with node 0.10.5

@victoruiz
Copy link

I'm also having this issue with node 0.10.21 and "exitOnError = false" and "handleExceptions: true"

@indexzero
Copy link
Member

Related to #327

@indexzero
Copy link
Member

Duplicate of #213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants