-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
MaxListenersExceedsWarning when used with http2 #87
Comments
Hi @akc42 I can definitely take a look! Can you provide me with an example I can see the issue so I can check it out in a debugger? Probably need at least all the following:
Just from the description, I'm not entirely sure there is anything that can be solved, since there isn't a memory leak. Do you have any thoughts on a possible solution off-hand? |
@dougwilson to answer your points
As I said, the client side is
and so on ... What happens is, if the browser cache is clear and it is not loading these files from cache, then a massive spike of overlapping requests hits the middleware that server static creates for the router. and the event emitter warning is triggered. It terms of a solution, my thoughts are that serve static could keep track of the number of parallel requests (by creating a static counter in the initial call to set up the middleware and then incrementing it just before |
Hi @akc42 sorry if I wasn't clear: it doesn't have to be your actual app, just an app. If you can't actually take some time to put together (3) and (4) so I can take a look, I think I have enough information to try to come up with an app and reproduction steps, but this is definitely on my back burner since that is going to add a lot of time I don't really have to figure this out. You're absolutely free to put together a pull request with a fix to get merged, of course ! As for your suggestion, I don't think that even makes sense. If we just keep incrementing the max listeners, then what is the purpose of even having a max at all? May as well simply disable the warning, right? |
I'll try and put something together that replicates the problem but is simple. It will take me a short while though as I am busy for a few days. |
@dougwilson https://github.com/akc42/maxListenerTest I think this answers your points 3 & 4 Re your response about not increasing max listeners. I don't agree with your assertion that there is no purpose to having max listeners if you just increase it. There is a purpose because other events in the system may actually be leaking listeners and you want to trap them. I am thinking that either |
Perhaps you misunderstood. I meant that in this case, on whoever the object is, it wouldn't have a purpose, since if I added one every time I added a listener, then if my code to remove the listener never runs (and thus decrements the max count), it would no longer catch the memory leak the warning is supposed to catch, effectively making it pointless to even try bumping the max. May as well just set the max to Complicating matters, this module support Node.js 0.8+ and there is no API in 0.8 (or 0.10 for that matter) to get the set max listeners, only set them, so just a single set to I'm not sure if there is anything I can do. If you have and ideas, I would welcome a pull request, as right now the right solution is eluding me, and I'm not sure how to move forward. Much appreciated! |
@akc42 I don't suppose you could recommend a quick solution to make the warning go away? |
My, rather simplistic solution (meaning I don't get all the extras from
This function is then used as router middlewhere
|
I am aware of #7 which was closed a while ago now. However the issue still is occurring for me, using node 7.10.0. I think that is probably because I am using the http2 as the server and because the app that it is serving is a polymer custom components one, so calling index.html does cause an immediate request for quite a large number of additional files (approx 40 if I remember correctly) which should be being served through serve-static.
I have put a trace on the warning and confirmed it comes from the
on-finished
module as expressed in #7. I have also puts some instrumentation in the module that is adding and removing the listeners, so I am pretty sure that although a lot are added they are all eventually removed again, to I don't think there is an actual memory leak happening.I report it here to see if there is anything that serve static could do to prevent the warning occuring
The text was updated successfully, but these errors were encountered: