When testing this library out I received the warning
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 17 error listeners added. Use emitter.setMaxListeners() to increase limit
I puzzled over why my code was adding so many listeners, before realising it was caused by microjob. I was about to dismiss microjob and look for an alternative when I realised that the default numbers of workers is equal to the number of OS threads. My machine has 16, which explains this behaviour.
I see that I can use MAX_WORKERS to set the number lower, but others may not realise this, or even realise that their core count is what's causing the issue.
Perhaps the number of listeners can be increased on >10 core CPUs (as node will warn after 10 listeners), or a custom runtime warning could be included explaining the cause.
Additional request, could we perhaps have a way to set max workers via an argument rather than requiring an environment variable? This would allow me to include it in an application configuration file instead of needing to modify my launch command.
Hi @benji7425 !
Thank you for exposing this issue!
Yes, I think both of your solutions are valid.
Also yes, I'm going to move the environment variable inside the worker pool configurations.
When testing this library out I received the warning
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 17 error listeners added. Use emitter.setMaxListeners() to increase limit
I puzzled over why my code was adding so many listeners, before realising it was caused by microjob. I was about to dismiss microjob and look for an alternative when I realised that the default numbers of workers is equal to the number of OS threads. My machine has 16, which explains this behaviour.
I see that I can use MAX_WORKERS to set the number lower, but others may not realise this, or even realise that their core count is what's causing the issue.
Perhaps the number of listeners can be increased on >10 core CPUs (as node will warn after 10 listeners), or a custom runtime warning could be included explaining the cause.
Additional request, could we perhaps have a way to set max workers via an argument rather than requiring an environment variable? This would allow me to include it in an application configuration file instead of needing to modify my launch command.