Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxListenersExceededWarning: Possible EventEmitter memory leak detected #1541

Open
tonymccallie opened this issue Aug 5, 2021 · 16 comments
Open
Labels
bug filed A bug has been filed upstream for this issue

Comments

@tonymccallie
Copy link

tonymccallie commented Aug 5, 2021

When connecting to more than 5 rooms (a necessity for us to handle groups larger than 50) we start getting these errors as soon as we connect the 6th room:

events.js:46 MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disabled listeners added. Use emitter.setMaxListeners() to increase limit
    at _addListener (https://api.url/vendor.cea7801f6e2b6e161ba2.js:1277:15)
    at LocalVideoTrack.addListener (https://api.url/vendor.cea7801f6e2b6e161ba2.js:1290:10)
    at LocalVideoTrackPublication.LocalTrackPublication (https://api.url/vendor.cea7801f6e2b6e161ba2.js:212192:11)
    at new LocalVideoTrackPublication (https://api.url/vendor.cea7801f6e2b6e161ba2.js:95251:137)
    at asLocalTrackPublication (https://api.url/vendor.cea7801f6e2b6e161ba2.js:195354:10)
    at LocalTrackPublicationV2.updated (https://api.url/vendor.cea7801f6e2b6e161ba2.js:115206:37)
    at LocalTrackPublicationV2.emit (https://api.url/vendor.cea7801f6e2b6e161ba2.js:1226:7)
    at LocalTrackPublicationV2.setSid (https://api.url/vendor.cea7801f6e2b6e161ba2.js:92952:14)
    at LocalTrackPublicationV2.setSid (https://api.url/vendor.cea7801f6e2b6e161ba2.js:225240:154)
    at LocalTrackPublicationV2.update (https://api.url/vendor.cea7801f6e2b6e161ba2.js:143969:16)

Can you increase the limit? Or how can we handle larger amounts of rooms/participants? We are needing to host events with possibly hundreds of participants.

@PikaJoyce PikaJoyce self-assigned this Aug 10, 2021
@PikaJoyce
Copy link
Contributor

Hi @tonymccallie,

Thank you for opening this issue. Could you please provide some more details on this? Such as what version of the SDK you're on, what browsers etc?

Regards,
Joyce

@tonymccallie
Copy link
Author

We are using twilio-video 2.15.3 and Chrome 92.0.4515.131 on macOS 11.5.1

@PikaJoyce
Copy link
Contributor

Thanks for those details @tonymccallie, could you also provide some repro steps as well?

I can't seem to reproduce this issue. Currently, I'm joining a room and disconnecting from the room, about 10x times without hitting that warning.

Best,
Joyce

@tonymccallie
Copy link
Author

Joyce,

The problem happens when you join six separate rooms at once.. for a broadcast.

Thanks, Tony

@PikaJoyce
Copy link
Contributor

Hi @tonymccallie,

I've attempted to reproduce this using our react app. Joined 6 rooms concurrently and added a 7th just for good measure, and still unable to reproduce this. Can you test out our react app to see if you're hitting these same issues?

Thanks,
Joyce

@tonymccallie
Copy link
Author

Did you publish media to the rooms? Or just connect. I should have clarified. Our entire app is built in Angular, not react.

@PikaJoyce
Copy link
Contributor

Hey @tonymccallie

Thank you for that information! I've got a repro going. Publish a single track, and in my case I was publishing a single video track, and it was being published to 10 different rooms. It seems that as a default, event emitters have a maximum of 10 listeners for a particular event.

Here's a couple of options:

  1. You mentioned wanting to do this for broadcasting, we currently have a private beta open for live streaming. So you'd have to request access if you'd like to utilize this feature.

  2. You can alternatively use videoTrack.setMaxListeners(n). I've applied this method on the localVideoTrack that is being published and simply increased it from the default 10, to 20.

Please let me know if this works for you!

Best,
Joyce

@tonymccallie
Copy link
Author

I'm glad you were able to reproduce this. I will try option 2 tomorrow and see if I can get that to work. I'll report back my findings.

Thanks, Tony

@tonymccallie
Copy link
Author

Joyce,

I was able to attach 8 rooms with no errors by setting videoTrack.setMaxListeners(20).

Thanks for your help!
Tony

@tonymccallie
Copy link
Author

A new problem though, this only pushes the problem out, it doesn't fix it. I was able to attach 8 rooms, but as soon as I detached those 8 rooms and added 8 new ones, I got the error again. We are working on an environment that is most likely on for 8 hours or more with several broadcasts of rooms starting and stopping. We will hit this error if the listeners aren't being cleaned up.

@PikaJoyce
Copy link
Contributor

Hi @tonymccallie,

Thanks for letting me know. I've filed an internal ticket to track this issue and investigate further. I'll keep this thread open and keep it updated.

Please let me know if you come across any other issues!

Thanks again,
Joyce

@tonymccallie
Copy link
Author

Joyce,

We met with Sergio today and were able to replicate the problem in Safari as well. He said he would try and contact you about this issue as well.

Thanks, Tony

@PikaJoyce PikaJoyce added the bug filed A bug has been filed upstream for this issue label Oct 19, 2021
@PikaJoyce
Copy link
Contributor

Hi @tonymccallie,

Many apologies for the late response. As you may have heard from Sergio, the internal ticket that was filed for this issue is VIDEO-6529. I'm updating this thread in order for us to continue tracking the issue!

Best,
Joyce

@canadaduane
Copy link

We encountered this today as well. If you switch rooms (join + leave) 10 or more times, this event emitter leak warning appears in the console.

I believe the issue is that there is no off or removeEventListener to match the on event listener at

localTrack._processorEventObserver.on('event', event => {

@PikaJoyce
Copy link
Contributor

Hi @canadaduane!

Thanks! I'll be handing this off to @manjeshbhargav.

Cheers

@PikaJoyce PikaJoyce removed their assignment Sep 26, 2023
@nsmithdev
Copy link

I'm having the same problem. We have a remote support app and if the support person connects/disconnects 10 times we receive this error on the person being helped side. The person being helped only ever connects a single room once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug filed A bug has been filed upstream for this issue
Projects
None yet
Development

No branches or pull requests

4 participants