-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fix MaxListenersExceededWarning
- "disconnected listeners" with disconnectEventAudienceMap
#78
base: master
Are you sure you want to change the base?
Conversation
…dign disconnect event
…rshan/sb/issue-12161
I started reviewing but have a couple questions and comments.
I ask because it looks like we're essentially doing what event listener does: store all the callback functions on an emitter into an object we can iterate over. I want to make sure this isn't also due to a real performance issue because from that standpoint the only piece that looks like it would run faster is removing event listeners, it's just now we manage calling the callbacks versus the emitter calling them.
|
Thanks for the comments, @chradek!!!
Not just session creation. Potentially, any "child" that is adding the listeners on the connection object. I had added a TODO in the description too if we decided to go with this solution.
Great question. That's the idea technically, and this seemed to be the only way I could prevent the addition of too many listeners.
That's exactly what I was thinking of too.. while implementing this "supposed fix". I'm also unsure if this fixes things..
Any thoughts, @chradek ? |
@chradek brings up a good point that I hadn't honestly thought about. In the previous fix, the potential number of registered listeners was one per message (ie, if we were doing "backup" message settlement). So it'd be difficult for us to really know what the cap is, but theoretically it could be something like 2000+. This particular one seems like it's centered around links - if that's the case then that number is likely to be very low (ie, I think even in our tests we ended up having 11 total (1 over the limit) so we're probably not in bad shape there to just bump up the max listeners. We actually already do bump up the limit to a much higher default than I anticipated for Senders: I would think that the simplicity of just using the built-in default rather than having something custom would outweigh potential efficiency gains, IMO. |
TODO: Have a parallel PR to bump the listeners limit to a higher number. |
Description
MaxListenersExceededWarning - "disconnected listeners" - Cause
(node:6245) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disconnected listeners added to [Connection]. Use emitter.setMaxListeners() to increase limit
Fix
TODO
Reference to any GitHub issues
@richardpark-msft @chradek @ramya-rao-a