Is .close() enough, or should we also call .removeAllListeners() on Transports, Producers, and Consumers?

Hi everyone,

I have a question about resource cleanup in mediasoup.

When removing a Transport, Producer, or Consumer, is calling .close() enough, or is it also recommended to call .removeAllListeners()?

For example:

producer.close();
producer.removeAllListeners();

and similarly for transports and consumers.

My understanding is that .close() should emit the appropriate events and release mediasoup resources, but I’m not sure whether manually calling .removeAllListeners() is considered best practice to avoid potential memory leaks, especially in long-running applications.

What is the recommended cleanup pattern in production applications?

Thanks!

Actually you should NEVER remove all listeners because you would also remove internal ones. If you do it after close() it’s ok because mediasoup classes don’t emit anything after closed but anyway there is no reason to do it.

Thanks, mate!