Skip to content

Commit

Permalink
doc: update http server response 'close' event
Browse files Browse the repository at this point in the history
Two places emits `close` events:

`resOnFinish` calls `emitCloseNT`, which happens when the result is
completed:
https://github.com/nodejs/node/blob/687dbd85263f433cc351c6daa83f9296a1d0bb4f/lib/_http_server.js#L695

It gets attached once the socket is assigned:
https://github.com/nodejs/node/blob/687dbd85263f433cc351c6daa83f9296a1d0bb4f/lib/_http_server.js#L226

And detached if the response is completed:
https://github.com/nodejs/node/blob/master/lib/_http_server.js#L709
https://github.com/nodejs/node/blob/687dbd85263f433cc351c6daa83f9296a1d0bb4f/lib/_http_server.js#L232

Which means, it can only be reached in this case, for premature socket
termination.

PR-URL: #34472
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
renatomariscal authored and addaleax committed Sep 22, 2020
1 parent e30ddac commit 75ed2f6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,8 @@ passed as the second parameter to the [`'request'`][] event.
added: v0.6.7
-->

Indicates that the underlying connection was terminated.
Indicates that the the response is completed, or its underlying connection was
terminated prematurely (before the response completion).

### Event: `'finish'`
<!-- YAML
Expand Down

0 comments on commit 75ed2f6

Please sign in to comment.