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 <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
renatomariscal authored and MylesBorins committed Aug 17, 2020
1 parent 5712f96 commit 60432e3
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 @@ -1335,7 +1335,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 60432e3

Please sign in to comment.