This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: fix ServerResponse does not emit 'close'
Refs #2453.
- Loading branch information
Showing
3 changed files
with
37 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dd9593c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think "assignSocket" is called every time on keep-alive connections. The "close" event listeners will just keep ramping up until hitting the listener limit.
dd9593c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a test case I can try? The logic seems okay to me and I see a removal for every added 'close' listener.
dd9593c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plain vanilla handler:
app.get('/test', function(req,res) {
res.end();
});
curl -v http://localhost:8888/test
Uncaught TypeError: Cannot call method 'emit' of null
at Socket.onServerResponseClose (http.js:780:21)
at Socket.emit (events.js:88:20)
at Array. (net.js:320:10)
at EventEmitter._tickCallback (node.js:192:40)
curl -v http://localhost:8888/test http://localhost:8888/test http://localhost:8888/test http://localhost:8888/test http://localhost:8888/test http://localhost:8888/test http://localhost:8888/test http://localhost:8888/test http://localhost:8888/test http://localhost:8888/test http://localhost:8888/test
server warning/exception:
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace:
at Socket. (events.js:139:15)
at ServerResponse.assignSocket (http.js:786:10)
at HTTPParser.onIncoming (http.js:1454:11)
at HTTPParser.onHeadersComplete (http.js:102:31)
at Socket.ondata (http.js:1387:22)
at TCP.onread (net.js:354:27)
dd9593c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably a bug in whatever library you're using. Below is a plain Node example that works fine with curl or
ab -k
:dd9593c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right. sorry for the trouble. it was an old piece of code which got included in my test. upgrade to 0.6.8 kicked the error in.
dd9593c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you resolve this? I've got the exact same error, but I'm not sure what old code would cause this.
edit: found the cause. It was the long-stack-traces module.