Skip to content

Commit 8799f43

Browse files
committed
http: revert "http: always emit close on req and res"
This reverts a commit that accidentally introduced a semver-major change to Node 10 and broke userland code. A subsequent fix to that change and documentation change are reverted with it. Revert "http: fix res emit close before user finish" This reverts commit 2a9c833. Revert "http: always emit close on req and res" This reverts commit 8029a24. Revert "doc: fix HTTP req/res 'close' description" This reverts commit 8ab7ea6. PR-URL: #21809 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
1 parent 3d05d82 commit 8799f43

File tree

3 files changed

+3
-32
lines changed

3 files changed

+3
-32
lines changed

doc/api/http.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,8 @@ interface. This is an [`EventEmitter`][] with the following events:
10151015
added: v0.6.7
10161016
-->
10171017

1018-
Indicates that the underlying connection was terminated.
1018+
Indicates that the underlying connection was terminated before
1019+
[`response.end()`][] was called or able to flush.
10191020

10201021
### Event: 'finish'
10211022
<!-- YAML
@@ -1505,6 +1506,7 @@ added: v0.4.2
15051506
-->
15061507

15071508
Indicates that the underlying connection was closed.
1509+
Just like `'end'`, this event occurs only once per response.
15081510

15091511
### message.aborted
15101512
<!-- YAML

lib/_http_server.js

-6
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,6 @@ function resOnFinish(req, res, socket, state, server) {
561561
req._dump();
562562

563563
res.detachSocket(socket);
564-
req.emit('close');
565-
process.nextTick(emitCloseNT, res);
566564

567565
if (res._last) {
568566
if (typeof socket.destroySoon === 'function') {
@@ -585,10 +583,6 @@ function resOnFinish(req, res, socket, state, server) {
585583
}
586584
}
587585

588-
function emitCloseNT(self) {
589-
self.emit('close');
590-
}
591-
592586
// The following callback is issued after the headers have been read on a
593587
// new message. In this callback we setup the response object and pass it
594588
// to the user.

test/parallel/test-http-req-res-close.js

-25
This file was deleted.

0 commit comments

Comments
 (0)