child-shell: MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 data listeners added. Use emitter.setMaxListeners() to increase limit

The code will cause this.streams.stderr to repeatedly listen for the same event:

const Shell = require("node-powershell");

const test = async () => {
  const ps = new Shell({
    executionPolicy: "Bypass",
    noProfile: true
  })
  for (let index = 0; index < 10; index++) {
    ps.addCommand(`echo ${index}`)
    const res = await ps.invoke()
    console.log("im index and res: %n %s", index, res)
  }
}
 test()

image

https://github.com/rannn505/node-powershell/blob/b0a0f7f33f7c0b07351e875007e97a20d217b420/lib/Shell.js#L174-L228

I have noticed that every time you run the invoke function, you will recreate the ShellStreamBuffer instance, this should be optimizable. https://github.com/rannn505/node-powershell/blob/b0a0f7f33f7c0b07351e875007e97a20d217b420/lib/Shell.js#L180

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@FloatingShuYin @zenion , A fix will be released with the next version. working on that πŸ˜ƒ

Thanks @rannn505 for your work! I am looking forward to giving 5.0.1 a spin πŸ˜‰

@sopelt image

Regarding the name thing, this version I implemented the NPS base classes with an abstract layer that would now allow me to apply a cover to any other shell I want quite easily and fast. The name of the package will not change but new packages (like node-bash etc …) will be added very soon. All of them will be here in this repo (and I plan to use lerna to manage all the new packages). it will be fun πŸ˜ƒ

@sopelt, I still have some small things left before I can release, but I won’t have enough time to fix them today. I believe it will be released tomorrow. Thank you for your patience.

@sopelt, I’m aiming for this Saturday 🀞