http: always emit close on req and res
PR-URL: https://github.com/nodejs/node/pull/20611 Fixes: https://github.com/nodejs/node/issues/20600 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
eafb30ccbf
commit
f22c7c10ca
@ -561,6 +561,8 @@ function resOnFinish(req, res, socket, state, server) {
|
||||
req._dump();
|
||||
|
||||
res.detachSocket(socket);
|
||||
req.emit('close');
|
||||
res.emit('close');
|
||||
|
||||
if (res._last) {
|
||||
if (typeof socket.destroySoon === 'function') {
|
||||
|
16
test/parallel/test-http-req-res-close.js
Normal file
16
test/parallel/test-http-req-res-close.js
Normal file
@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const http = require('http');
|
||||
|
||||
const server = http.Server(common.mustCall((req, res) => {
|
||||
res.end();
|
||||
res.on('finish', common.mustCall());
|
||||
res.on('close', common.mustCall());
|
||||
req.on('close', common.mustCall());
|
||||
res.socket.on('close', () => server.close());
|
||||
}));
|
||||
|
||||
server.listen(0, common.mustCall(() => {
|
||||
http.get({ port: server.address().port }, common.mustCall());
|
||||
}));
|
Loading…
x
Reference in New Issue
Block a user