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 2021-05-13 02:26:48 +03:00 committed by James M Snell
parent 6e6663b8a4
commit cbe0f0959e
No known key found for this signature in database
GPG Key ID: 7341B15C070877AC

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({