Skip to content

Commit

Permalink
test: stream.finished detects a destroyed IncomingMessage
Browse files Browse the repository at this point in the history
Add a test to verify that stream.finished works correctly
on IncomingMessage

refs: #38657

PR-URL: #38661
Refs: #38657
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Linkgoron authored and targos committed May 18, 2021
1 parent 5b40e2f commit 8eea317
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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({
Expand Down

0 comments on commit 8eea317

Please sign in to comment.