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
EventEmitter leak in 2.80 #2575
Comments
Adds .timings array with DNC, TCP, request and response times
I think I found it 60f6a00#commitcomment-21154407 @FredKSchott @nicjansma do you wanna take a look? |
That looks like the issue. The application uses keep-alive connections. |
I'm wondering if the best course of action is to just remove this feature. It doesn't actually work during keep-alive and keep-alive is entirely transparent to the user so the timings object just wont' have this information sometimes and it isn't entirely predictable when they will have it. |
Or it could check if the socket is already connected and just set the |
That's probably worse. People will make really bad assumptions about that. |
See #2566 for an updated PR that works for keep-alive. Do you think it's sufficient to change the |
@nicjansma no, that won't work. The problem isn't that it isn't being cleaned up after being called it's that it is probably never called. |
@nicjansma one thing you'll need to consider is that socket level metrics simply aren't applicable in the keep-alive scenario and that being in keep-alive isn't always predictable by your consumers. |
@mikeal Ah, that makes sense. I can update the handling to ensure the listener is removed, and validate that the socket object isn't kept alive. Yep, I understand the concerns about the Keep-Alive scenario. In that case, the connect time will be set to the dns time (which will be set to the socket time which will be set to the start time) if any of the phases don't occur. This roughly matches the ResourceTiming processing model. |
you probably do want to use once, but you also probably want to set a property for when connect has already been fired so that you can avoid adding the handler again. |
@nicjansma ping me when the PR gets updated :) |
@mikeal Absolutely, working on it! |
@mikeal @nicjansma will a newer version be published for this patch? |
After upgrading to 2.80, I was getting this error in production:
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect listeners added. Use emitter.setMaxListeners() to increase limit
The node.js processes quickly grew to 1-2 GB of resident memory (normally 300 MB) and then CPU load started spiking.
Rolled back to 2.79 and the issue went away.
The text was updated successfully, but these errors were encountered: