Skip to content

Commit 8029a24

Browse files
ronagaddaleax
authored andcommitted
http: always emit close on req and res
PR-URL: #20611Fixes: #20600 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 2db83fd commit 8029a24

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎lib/_http_server.js‎

Lines changed: 2 additions & 0 deletions
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(typeofsocket.destroySoon==='function'){
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
constcommon=require('../common');
4+
consthttp=require('http');
5+
6+
constserver=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)