Skip to content

Commit 8eea317

Browse files
Linkgorontargos
authored andcommitted
test: stream.finished detects a destroyed IncomingMessage
Add a test to verify that stream.finished works correctly on IncomingMessage refs: #38657 PR-URL: #38661 Refs: #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>
1 parent 5b40e2f commit 8eea317

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

test/parallel/test-stream-finished.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,14 +553,14 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
553553
}
554554

555555
{
556-
const server = http.createServer((req, res) => {
557-
res.on('close', () => {
556+
const server = http.createServer(common.mustCall((req, res) => {
557+
res.on('close', common.mustCall(() => {
558558
finished(res, common.mustCall(() => {
559559
server.close();
560560
}));
561-
});
561+
}));
562562
res.end();
563-
})
563+
}))
564564
.listen(0, function() {
565565
http.request({
566566
method: 'GET',
@@ -570,6 +570,22 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
570570
});
571571
}
572572

573+
{
574+
const server = http.createServer(common.mustCall((req, res) => {
575+
req.on('close', common.mustCall(() => {
576+
finished(req, common.mustCall(() => {
577+
server.close();
578+
}));
579+
}));
580+
req.destroy();
581+
})).listen(0, function() {
582+
http.request({
583+
method: 'GET',
584+
port: this.address().port
585+
}).end().on('error', common.mustCall());
586+
});
587+
}
588+
573589

574590
{
575591
const w = new Writable({

0 commit comments

Comments
 (0)