MaxListenersExceededWarning: Possible EventEmitter memory leak detected

Hi, after several inputs and outputs from the session, such a warning appears in the console. This is strange because we turn off all event listeners (client.on) after their session exits (

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ThreadPoolReady listeners added. Use emitter.setMaxListeners() to increase limit  (index.umd.js?af5c:1)
    at N (webpack-internal:///./node_modules/@zoom/videosdk/dist/index.umd.js:1:258275)
    at O.addListener (webpack-internal:///./node_modules/@zoom/videosdk/dist/index.umd.js:1:260322)
    at new e (webpack-internal:///./node_modules/@zoom/videosdk/dist/index.umd.js:1:270947)
    at new r (webpack-internal:///./node_modules/@zoom/videosdk/dist/index.umd.js:1:291335)
    at He (
    at t.prepareVBfile (
    at e.JsMediaSDK_PreLoad (
    at fs.setAssetsAndConstraint (webpack-internal:///./node_modules/@zoom/videosdk/dist/index.umd.js:1:120148)
    at t.eval [as _tapNext] (webpack-internal:///./node_modules/@zoom/videosdk/dist/index.umd.js:1:406804)
    at t._next (webpack-internal:///./node_modules/@zoom/videosdk/dist/index.umd.js:1:47533)

We have a global controller for all listeners.
Here’s how we add listeners:

  public addEventListener(event: EZoomEvent, listener: (payload: any) => void) {
    this.eventListeners[event] = listener;
    this.client.on(event, listener); // function VideoClient.on(event: string, callback: (payload: any) => void): void (+50 overloads)

This is how we remove all listeners when exiting a session:

  public removeEventListeners() {
    Object.entries(this.eventListeners).forEach(([event, listener]) => {
      if (listener), listener);  // function string, callback: (payload: any) => void): void

in use:

addZoomListeners() {
    ZOOM.addEventListener(EZoomEvent.userAdded, this.onUserAddedListener);
    ZOOM.addEventListener(EZoomEvent.userRemoved, this.onUserRemovedListener);
    ZOOM.addEventListener(EZoomEvent.userUpdated, this.onUserUpdatedListener);
    ZOOM.addEventListener(EZoomEvent.mediaSdkChange, this.onMediaSdkChange);

We also do the destruction of the client when exiting the session:


Hey @efron.vit

Thanks for your feedback.

We will fix this issue in the next release.


1 Like