GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http: wait for pending responses in closeIdleConnections · nodejs/node@9c699bd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _http_server.js
  • test/parallel
    • test-http-server-close-idle-wait-response.js
Expand file treeCollapse file tree
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

‎test/parallel/test-http-server-close-idle-wait-response.js‎

Copy file name to clipboard
+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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.