Uh oh!
There was an error while loading. Please reload this page.
http: avoid retaining unneeded memory - #11926
Conversation
There was a problem hiding this comment.
I'm not sure if this is ok but there are 2 listeners for the drain event and both seem to be useless for upgrade requests.
The first checks if _httpMessage is set and this is never true for upgrade requests.
The second checks if the socket is _paused but unless I'm missing something this flag is never set for upgrade requests.
There was a problem hiding this comment.
.removeAllListeners() also removes any user-installed 'drain' event listeners so no, probably not a good idea.
There was a problem hiding this comment.
Yeah I get that but can a user add a listener for the drain event before this is called?
There was a problem hiding this comment.
Yes, server.on('connection', c => c.on('drain', ondrain)).
4b1709a to
5c2d743Comparejasnell
commented
Mar 20, 2017
/cc @nodejs/http |
lpinca
commented
Mar 20, 2017
Refs: #11868 |
There was a problem hiding this comment.
.removeAllListeners() also removes any user-installed 'drain' event listeners so no, probably not a good idea.
5c2d743 to
b435591Comparelpinca
commented
Mar 20, 2017
@bnoordhuis updated, PTAL. |
bnoordhuis
commented
Mar 20, 2017
@lpinca You could move it to |
lpinca
commented
Mar 20, 2017
Done, thanks. |
There was a problem hiding this comment.
I'd add a comma, saves one line in the diff next time someone adds a property.
295bd86 to
76b237bComparejasnell
commented
Mar 22, 2017
jasnell
commented
Mar 22, 2017
@lpinca ... this is not landing cleanly for some reason (even tho it shows zero conflicts...) can you please squash the commits, rebase, and I'll try again. |
Prevent the events listeners of the sockets obtained with the HTTP upgrade mechanism from retaining unneeded memory. Refs: nodejs#11868
76b237b to
0100984Comparelpinca
commented
Mar 22, 2017
@jasnell done. |
jasnell
commented
Mar 22, 2017
Landed in e0a9ad1 |
MylesBorins
commented
Mar 28, 2017
This will need to be manually backported to v7.x |
Prevent the events listeners of the sockets obtained with the HTTP upgrade mechanism from retaining unneeded memory. Ref: nodejs#11868 PR-URL: nodejs#11926 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins
commented
Apr 10, 2017
Looks like this change is breaking spdy. Example breakage from spdy tests. |
ronkorving
commented
Apr 11, 2017
@indutny Any chance this could be solved on the spdy side of things? |
bnoordhuis
commented
Apr 11, 2017
Removing the backport-to-v7.x label and adding dont-land-on labels until this is resolved. |
lpinca
commented
Apr 11, 2017
Not sure if the following is the proper way to fix the issue but it seems to work: diff --git a/lib/spdy/server.js b/lib/spdy/server.js
index 777f682..d5321c2 100644
--- a/lib/spdy/server.js+++ b/lib/spdy/server.js@@ -189,6 +189,8 @@ proto._onStream = function _onStream (stream) {
socket = new net.Socket(socketOptions)
}
+ socket.server = this;+
handle.assignSocket(socket)
// For v0.8
Will send a PR. |
lpinca
commented
Apr 11, 2017
That patch seems to not work on Node.js 0.10 and 0.12. The problem is that |
Fixes a regression that caused an error to be thrown when trying to emit the 'timeout' event on the server referenced by `socket.server`. Fixes: nodejs#13435 Refs: nodejs#11926
Prevents the events listeners of the sockets obtained with the HTTP upgrade mechanism from retaining unneeded objects like
state.Reduces memory usage by ~20%.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)