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: add note regarding net.Socket default timeout #31379

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,9 @@ added: v0.1.90
Sets the socket to timeout after `timeout` milliseconds of inactivity on
the socket. By default `net.Socket` do not have a timeout.

Prior to Node.js 13.0.0, [`http.Server`][], [`https.Server`][] and
[`http2.Http2Server`][] have a different default socket timeout value.
Copy link
Member

Choose a reason for hiding this comment

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

Can we incorporate this information into the YAML matter instead of having it here?

Copy link
Member

Choose a reason for hiding this comment

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

Can we incorporate this information into the YAML matter instead of having it here?

Oh, wait, no, not that YAML matter. What's the rationale for putting this in net instead of http, https, and http2 docs?

Copy link
Contributor Author

@aduh95 aduh95 Feb 4, 2020

Choose a reason for hiding this comment

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

Apparently some users are referring to net docs when working with http.Server (see #31378); prior to Node.js 13, default values are consistent across all sockets in Node.js codebase EXCEPT for the timeout, I figured adding a note would help avoid the confusion.
Users who refer to http[s2] docs already have the correct information, I'm not sure there is much confusion from that side.


When an idle timeout is triggered the socket will receive a [`'timeout'`][]
event but the connection will not be severed. The user must manually call
[`socket.end()`][] or [`socket.destroy()`][] to end the connection.
Expand Down Expand Up @@ -1244,6 +1247,9 @@ Returns `true` if input is a version 6 IP address, otherwise returns `false`.
[`net.createConnection(port, host)`]: #net_net_createconnection_port_host_connectlistener
[`net.createServer()`]: #net_net_createserver_options_connectionlistener
[`new net.Socket(options)`]: #net_new_net_socket_options
[`http.Server`]: http.html#http_class_http_server
[`http2.Http2Server`]: http2.html#http2_class_http2server
[`https.Server`]: https.html#https_class_https_server
[`readable.setEncoding()`]: stream.html#stream_readable_setencoding_encoding
[`server.close()`]: #net_server_close_callback
[`server.getConnections()`]: #net_server_getconnections_callback
Expand Down