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: clarify socket and keepAliveTimeout interaction #25748

Closed

Conversation

inversion
Copy link
Contributor

@inversion inversion commented Jan 27, 2019

doc: clarify socket and keepAliveTimeout interaction

Socket timeouts set using the connection event are replaced by
server.keepAliveTimeout when a response is handled.

Socket timeouts set in the connection event are replaced after a response is sent in the resOnFinish handler

server.on('connection', function(socket) {
  socket.setTimeout(60000);
});

In this case, the socket timeout is 60 seconds until a response is sent, at which point it becomes 5 seconds (the server.keepAliveTimeout default). This bit me when working with load balancers that maintain long-lived connections.

I have added a note to the connection event docs to the effect that is preferred to use server.keepAliveTimeout.

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 Jan 27, 2019
@inversion inversion force-pushed the doc-clarify-http-keepAliveTimeout branch from 344dfc6 to 4696232 Compare January 28, 2019 00:21
@mscdex
Copy link
Contributor

mscdex commented Jan 28, 2019

The subsystem prefix in commit messages for doc-only changes should be doc instead of the specific core module name.

@@ -901,6 +901,10 @@ also be accessed at `request.connection`.
This event can also be explicitly emitted by users to inject connections
into the HTTP server. In that case, any [`Duplex`][] stream can be passed.

If `socket.setTimeout()` is called here, note that the timeout will
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If `socket.setTimeout()` is called here, note that the timeout will
If `socket.setTimeout()` is called here, the timeout will

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Trott Are we landing as is or can we add this fix on landing?

Copy link
Member

@lpinca lpinca Feb 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inversion are you ok with @Trott suggestion? If so please accept it so this can land.
Thank you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My change is non-blocking. It's not crucial that note that be removed. (It can also be removed by someone else who is landing this--just push to the branch. Or it can be removed in a subsequent PR as I imagine there are lots of opportunities for cleanup in the doc file.)

@Trott
Copy link
Member

Trott commented Jan 28, 2019

Hi, @inversion! Welcome and thanks for the pull request! Sorry to hear that this behavior caused you some grief!

/ping @nodejs/http to confirm that the behavior described here is correct and is currently undocumented.

/ping @nodejs/documentation Maybe there's a way to simplify or clarify the wording here a bit? Maybe a small piece of sample code with comments indicating the values and when they change? Or is that too much documentation real estate to describe what is likely an edge case?

@inversion
Copy link
Contributor Author

The subsystem prefix in commit messages for doc-only changes should be doc instead of the specific core module name.

I'll fix this, probably worth adding it to https://github.com/nodejs/node/blob/master/doc/guides/contributing/pull-requests.md#commit-message-guidelines

Socket timeouts set using the `connection` event are replaced by
server.keepAliveTimeout when a response is handled.
@Trott Trott force-pushed the doc-clarify-http-keepAliveTimeout branch from 4696232 to 5f761e9 Compare January 28, 2019 20:56
@Trott
Copy link
Member

Trott commented Jan 28, 2019

I fixed up the commit message subsystem, rebased against master, and force-pushed.

Lite CI: https://ci.nodejs.org/job/node-test-pull-request-lite-pipeline/2423/

@Trott Trott changed the title http: Clarify socket and keepAliveTimeout interaction doc: clarify socket and keepAliveTimeout interaction Jan 28, 2019
@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 28, 2019
@inversion
Copy link
Contributor Author

Thanks very much @Trott !

@Trott
Copy link
Member

Trott commented Feb 3, 2019

@nodejs/collaborators This could use another review.

lpinca added a commit to lpinca/node that referenced this pull request Feb 4, 2019
`Socket.prototype.setTimeout()` clears the previous timer before setting
a new one.

Refs: nodejs#25748 (comment)
addaleax pushed a commit that referenced this pull request Feb 6, 2019
`Socket.prototype.setTimeout()` clears the previous timer before setting
a new one.

Refs: #25748 (comment)

PR-URL: #25928
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit that referenced this pull request Feb 6, 2019
`Socket.prototype.setTimeout()` clears the previous timer before setting
a new one.

Refs: #25748 (comment)

PR-URL: #25928
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lpinca
Copy link
Member

lpinca commented Feb 8, 2019

@lpinca
Copy link
Member

lpinca commented Feb 9, 2019

Landed in 02601c2.

@lpinca lpinca closed this Feb 9, 2019
lpinca pushed a commit that referenced this pull request Feb 9, 2019
Socket timeouts set using the `'connection'` event are replaced by
`server.keepAliveTimeout` when a response is handled.

PR-URL: #25748
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@inversion inversion deleted the doc-clarify-http-keepAliveTimeout branch February 9, 2019 11:16
targos pushed a commit that referenced this pull request Feb 10, 2019
Socket timeouts set using the `'connection'` event are replaced by
`server.keepAliveTimeout` when a response is handled.

PR-URL: #25748
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@targos targos mentioned this pull request Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. 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.

7 participants