X Tutup
The Wayback Machine - https://web.archive.org/web/20220423172414/https://github.com/nodejs/node/pull/34472
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update http server response 'close' event #34472

Closed

Conversation

Copy link
Contributor

@renatomariscal renatomariscal commented Jul 22, 2020

Two places emits close events:

1 - On result completion:

resOnFinish calls emitCloseNT, which happens when the result is completed:

function resOnFinish(req, res, socket, state, server) {

2 - When the connection is terminated

It gets attached once the socket is assigned:

socket.on('close', onServerResponseClose);

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

ServerResponse.prototype.detachSocket = function detachSocket(socket) {

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

Checklist

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.
@nodejs-github-bot nodejs-github-bot added doc http labels Jul 22, 2020
@Trott
Copy link
Member

@Trott Trott commented Jul 23, 2020

@renatomariscal renatomariscal requested a review from as a code owner Aug 10, 2020
Trott pushed a commit that referenced this issue Aug 11, 2020
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>
@Trott
Copy link
Member

@Trott Trott commented Aug 11, 2020

Landed in f8a0e62
Thanks for the contribution! 🎉

@Trott Trott closed this Aug 11, 2020
MylesBorins pushed a commit that referenced this issue Aug 17, 2020
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>
@danielleadams danielleadams mentioned this pull request Aug 20, 2020
BethGriggs pushed a commit that referenced this issue Aug 20, 2020
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>
addaleax pushed a commit that referenced this issue Sep 22, 2020
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>
addaleax pushed a commit that referenced this issue Sep 22, 2020
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>
@codebytere codebytere mentioned this pull request Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc http
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants
X Tutup