You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
net.connect options noDelay, keepAlive, keepAliveInitialDelay should be in the constructor instead #59823
The documentation for the connect method on net.Socket (https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) says that there are options noDelay, keepAlive, keepAliveInitialDelay. However, by looking at the source code, these options are in fact instead for the constructor of new net.Socket.
Therefore, this code won't work (the last three options will be ignored):
Moving them to the options passed to the constructor instead will make it work.
This issue can easily be verified with strace on Linux.
I suggest to fix the documentation to match the actual behaviour rather than changing the implementation to match the documentation. Looking at what options are available for the constructor vs. the connect method, it makes more sense to have these options in the constructor, since the connect method only have options regarding to the actual connection attempt (such as what host, port, ip family etc. to use for the connection attempt), while the socket constructor takes options to use for the socket itself, such as if half-open should be enabled etc.
It seems this issue has been present ever since these new options were added in #41310. Note that if you use the net.createConnection factory method, you won't notice the issue since the same options are passed to both methods.
Hi @Emill, I’d like to work on this issue.
I can update the documentation to correctly move the noDelay, keepAlive, and keepAliveInitialDelay options to the net.Socket constructor section, and remove them from the connect method section.
Activity
bablukup commentedon Sep 14, 2025
Hi @Emill, I’d like to work on this issue.
I can update the documentation to correctly move the
noDelay,keepAlive, andkeepAliveInitialDelayoptions to thenet.Socketconstructor section, and remove them from theconnectmethod section.Please confirm if I can take this issue.
Emill commentedon Sep 14, 2025
No problem for me :)
doc: correct options for net.Socket class and socket.connect
doc: correct options for net.Socket class and socket.connect
doc: correct options for net.Socket class and socket.connect
doc: correct options for net.Socket class and socket.connect
doc: correct options for net.Socket class and socket.connect
doc: correct options for net.Socket class and socket.connect
doc: correct options for net.Socket class and socket.connect
doc: correct options for net.Socket class and socket.connect
doc: correct options for net.Socket class and socket.connect
doc: correct options for net.Socket class and socket.connect