Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 825a683

Browse filesBrowse files
ronagtargos
authored andcommitted
http: response should always emit 'close'
Fixes: #40528 PR-URL: #40543 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent b320387 commit 825a683
Copy full SHA for 825a683

File tree

Expand file treeCollapse file tree

2 files changed

+23
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+23
-1
lines changed
Open diff view settings
Collapse file

‎lib/_http_server.js‎

Copy file name to clipboardExpand all lines: lib/_http_server.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ function resOnFinish(req, res, socket, state, server) {
839839
}
840840

841841
function emitCloseNT(self) {
842-
if (!self.destroyed) {
842+
if (!self._closed) {
843843
self.destroyed = true;
844844
self._closed = true;
845845
self.emit('close');
Collapse file

‎test/parallel/test-http-response-close.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-response-close.js
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,25 @@ const assert = require('assert');
7878
})
7979
);
8080
}
81+
82+
{
83+
const server = http.createServer(
84+
common.mustCall((req, res) => {
85+
res.on('close', common.mustCall());
86+
res.destroy();
87+
})
88+
);
89+
90+
server.listen(
91+
0,
92+
common.mustCall(() => {
93+
http.get(
94+
{ port: server.address().port },
95+
common.mustNotCall()
96+
)
97+
.on('error', common.mustCall(() => {
98+
server.close();
99+
}));
100+
})
101+
);
102+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.