tls: forward keepAlive, keepAliveInitialDelay, noDelay to socket · nodejs/node@bf1ed7e · GitHub
Skip to content

Commit bf1ed7e

Browse files
tadjik1richardlau
authored andcommitted
tls: forward keepAlive, keepAliveInitialDelay, noDelay to socket
`tls.connect()` silently ignores `keepAlive`, `keepAliveInitialDelay`, and `noDelay` options. The documentation states it accepts any `socket.connect()` option, and `net.createConnection()` with the same options works correctly. Forward the options through both code paths so `net.Socket`'s constructor stores them on the internal symbols (`kSetNoDelay`, `kSetKeepAlive`, `kSetKeepAliveInitialDelay`), which `afterConnect()` then applies to the handle. Fixes: #62003 PR-URL: #62004 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
1 parent e55edde commit bf1ed7e

4 files changed

Lines changed: 77 additions & 3 deletions

File tree

lib/internal/net.js

Lines changed: 3 additions & 0 deletions

lib/internal/tls/wrap.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,9 @@ function TLSSocket(socket, opts) {
590590
highWaterMark: tlsOptions.highWaterMark,
591591
onread: !socket ? tlsOptions.onread : null,
592592
signal: tlsOptions.signal,
593+
noDelay: tlsOptions.noDelay,
594+
keepAlive: tlsOptions.keepAlive,
595+
keepAliveInitialDelay: tlsOptions.keepAliveInitialDelay,
593596
});
594597

595598
// Proxy for API compatibility
@@ -1755,6 +1758,9 @@ exports.connect = function connect(...args) {
17551758
highWaterMark: options.highWaterMark,
17561759
onread: options.onread,
17571760
signal: options.signal,
1761+
noDelay: options.noDelay,
1762+
keepAlive: options.keepAlive,
1763+
keepAliveInitialDelay: options.keepAliveInitialDelay,
17581764
});
17591765

17601766
// rejectUnauthorized property can be explicitly defined as `undefined`

lib/net.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ let debug = require('internal/util/debuglog').debuglog('net', (fn) => {
4848
});
4949
const {
5050
kReinitializeHandle,
51+
kSetNoDelay,
52+
kSetKeepAlive,
53+
kSetKeepAliveInitialDelay,
5154
isIP,
5255
isIPv4,
5356
isIPv6,
@@ -356,9 +359,6 @@ function closeSocketHandle(self, isException, isCleanupPending = false) {
356359

357360
const kBytesRead = Symbol('kBytesRead');
358361
const kBytesWritten = Symbol('kBytesWritten');
359-
const kSetNoDelay = Symbol('kSetNoDelay');
360-
const kSetKeepAlive = Symbol('kSetKeepAlive');
361-
const kSetKeepAliveInitialDelay = Symbol('kSetKeepAliveInitialDelay');
362362
const kSetTOS = Symbol('kSetTOS');
363363

364364
function Socket(options) {
Lines changed: 65 additions & 0 deletions

0 commit comments

Comments
 (0)