Skip to content

Piping a simple program to stdout gives "MaxListenersExceededWarning: Possible EventEmitter memory leak detected when" #16767

@mafintosh

Description

@mafintosh
  • Version: v8.9.0
  • Platform: Linux brunhilde 4.13.8-1-ARCH deps: update openssl to 1.0.1j #1 SMP PREEMPT Wed Oct 18 11:49:44 CEST 2017 x86_64 GNU/Linux
  • Subsystem: console.js

When running a program that produces a lot of output that is consumed by another program in the pipeline, Node gives memory leak errors.

To reproduce try saving this simple program:

// save as bug.js
for (var i = 0; i < 10000; i++) {
  console.log('line ' + i)
}

Then run

node bug.js | less

And quit less (type q). This results in the following warning being printed out:

(node:31009) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit

@mcollina mentioned it is most likely a bug here, https://github.com/nodejs/node/blob/master/lib/console.js#L91-L119

(In general it would be useful as well if the memory leak errors printed out a stack trace so it was easier to hunt down the causes)

/cc @mcollina @addaleax

Metadata

Metadata

Assignees

No one assigned

    Labels

    consoleIssues and PRs related to the console subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions