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

renatomariscal
Copy link
Contributor

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

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem. labels Jul 22, 2020
@Trott
Copy link
Member

Trott commented Jul 23, 2020

@nodejs/http @addaleax @ronag

@renatomariscal renatomariscal requested a review from a team as a code owner August 10, 2020 16:06
Trott pushed a commit that referenced this pull request 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 <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@Trott
Copy link
Member

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 pull request 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 <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@danielleadams danielleadams mentioned this pull request Aug 20, 2020
BethGriggs pushed a commit that referenced this pull request 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 <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
addaleax pushed a commit that referenced this pull request 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 <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
addaleax pushed a commit that referenced this pull request 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 <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@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 Issues and PRs related to the documentations. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants