Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8ccfb87

Browse filesBrowse files
indutnyMylesBorins
authored andcommitted
http: unref socket timer on parser execute
When underlying `net.Socket` instance is consumed in http server - no `data` events are emitted, and thus `socket.setTimeout` fires the callback even if the data is constantly flowing into the socket. Fix this by calling `socket._unrefTimer()` on every `onParserExecute` call. Fix: #5899 PR-URL: #6286 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8779967 commit 8ccfb87
Copy full SHA for 8ccfb87

File tree

Expand file treeCollapse file tree

2 files changed

+37
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+37
-0
lines changed
Open diff view settings
Collapse file

‎lib/_http_server.js‎

Copy file name to clipboardExpand all lines: lib/_http_server.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ function connectionListener(socket) {
364364
}
365365

366366
function onParserExecute(ret, d) {
367+
socket._unrefTimer();
367368
debug('SERVER socketOnParserExecute %d', ret);
368369
onParserExecuteCommon(ret, undefined);
369370
}
Collapse file
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const http = require('http');
6+
7+
const server = http.createServer((req, res) => {
8+
server.close();
9+
10+
res.writeHead(200);
11+
res.flushHeaders();
12+
13+
req.setTimeout(common.platformTimeout(200), () => {
14+
assert(false, 'Should not happen');
15+
});
16+
req.resume();
17+
req.once('end', common.mustCall(() => {
18+
res.end();
19+
}));
20+
});
21+
22+
server.listen(common.PORT, common.mustCall(() => {
23+
const req = http.request({
24+
port: common.PORT,
25+
method: 'POST'
26+
}, (res) => {
27+
const interval = setInterval(() => {
28+
req.write('a');
29+
}, common.platformTimeout(25));
30+
setTimeout(() => {
31+
clearInterval(interval);
32+
req.end();
33+
}, common.platformTimeout(400));
34+
});
35+
req.write('.');
36+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.