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 9c699bd

Browse filesBrowse files
ShogunPandadanielleadams
authored andcommitted
http: wait for pending responses in closeIdleConnections
PR-URL: #43890 Fixes: #43771 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 9f9d00c commit 9c699bd
Copy full SHA for 9c699bd

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

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

‎lib/_http_server.js‎

Copy file name to clipboardExpand all lines: lib/_http_server.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ Server.prototype.closeIdleConnections = function() {
494494
const connections = this[kConnections].idle();
495495

496496
for (let i = 0, l = connections.length; i < l; i++) {
497+
if (connections[i].socket._httpMessage && !connections[i].socket._httpMessage.finished) {
498+
continue;
499+
}
500+
497501
connections[i].socket.destroy();
498502
}
499503
};
Collapse file
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
const { createServer, get } = require('http');
6+
7+
const server = createServer(common.mustCall(function(req, res) {
8+
req.resume();
9+
10+
setTimeout(common.mustCall(() => {
11+
res.writeHead(204, { 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=1' });
12+
res.end();
13+
}), common.platformTimeout(1000));
14+
}));
15+
16+
server.listen(0, function() {
17+
const port = server.address().port;
18+
19+
get(`http://localhost:${port}`, common.mustCall((res) => {
20+
server.close();
21+
})).on('finish', common.mustCall(() => {
22+
setTimeout(common.mustCall(() => {
23+
server.closeIdleConnections();
24+
}), common.platformTimeout(500));
25+
}));
26+
});

0 commit comments

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