Skip to content

Commit 8029a24

Browse files
ronagaddaleax
authored andcommitted
http: always emit close on req and res
PR-URL: #20611 Fixes: #20600 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 2db83fd commit 8029a24

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/_http_server.js

+2
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,8 @@ function resOnFinish(req, res, socket, state, server) {
561561
req._dump();
562562

563563
res.detachSocket(socket);
564+
req.emit('close');
565+
res.emit('close');
564566

565567
if (res._last) {
566568
if (typeof socket.destroySoon === 'function') {
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const http = require('http');
5+
6+
const server = http.Server(common.mustCall((req, res) => {
7+
res.end();
8+
res.on('finish', common.mustCall());
9+
res.on('close', common.mustCall());
10+
req.on('close', common.mustCall());
11+
res.socket.on('close', () => server.close());
12+
}));
13+
14+
server.listen(0, common.mustCall(() => {
15+
http.get({ port: server.address().port }, common.mustCall());
16+
}));

0 commit comments

Comments
 (0)