test: stream.finished detects a destroyed IncomingMessage

Add a test to verify that stream.finished works correctly
on IncomingMessage

refs: https://github.com/nodejs/node/issues/38657

PR-URL: https://github.com/nodejs/node/pull/38661
Refs: https://github.com/nodejs/node/issues/38657
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Nitzan Uziely authored and Michaël Zasso committed 2021-05-18 13:10:09 +02:00
1 parent 5b40e2f596
commit 8eea317227
1 file changed
+20 -4
+20 -4
View File
@@ -553,14 +553,14 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
}
{
const server = http.createServer((req, res) => {
res.on('close', () => {
const server = http.createServer(common.mustCall((req, res) => {
res.on('close', common.mustCall(() => {
finished(res, common.mustCall(() => {
server.close();
}));
});
}));
res.end();
})
}))
.listen(0, function() {
http.request({
method: 'GET',
@@ -570,6 +570,22 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
});
}
{
const server = http.createServer(common.mustCall((req, res) => {
req.on('close', common.mustCall(() => {
finished(req, common.mustCall(() => {
server.close();
}));
}));
req.destroy();
})).listen(0, function() {
http.request({
method: 'GET',
port: this.address().port
}).end().on('error', common.mustCall());
});
}
{
const w = new Writable({