File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1023,6 +1023,9 @@ being issued by trusted CA (`options.ca`).
10231023<!-- YAML
10241024added: v0.11.3
10251025changes:
1026+ - version: REPLACEME
1027+ pr-url: https://github.com/nodejs/node/pull/25517
1028+ description: The `timeout` option is supported now.
10261029 - version: v8.0.0
10271030 pr-url: https://github.com/nodejs/node/pull/12839
10281031 description: The `lookup` option is supported now.
@@ -1088,6 +1091,9 @@ changes:
10881091 ` tls.createSecureContext() ` .
10891092 * ` lookup ` : {Function} Custom lookup function. ** Default:**
10901093 [ ` dns.lookup() ` ] [ ] .
1094+ * ` timeout ` : {number} If set and if a socket is created internally, will call
1095+ [ ` socket.setTimeout(timeout) ` ] [ ] after the socket is created, but before it
1096+ starts the connection.
10911097 * ...: [ ` tls.createSecureContext() ` ] [ ] options that are used if the
10921098 ` secureContext ` option is missing, otherwise they are ignored.
10931099* ` callback ` {Function}
@@ -1541,6 +1547,7 @@ where `secureSocket` has the same API as `pair.cleartext`.
15411547[ `server.getTicketKeys()` ] : #tls_server_getticketkeys
15421548[ `server.listen()` ] : net.html#net_server_listen
15431549[ `server.setTicketKeys()` ] : #tls_server_setticketkeys_keys
1550+ [ `socket.setTimeout(timeout)` ] : #net_socket_settimeout_timeout_callback
15441551[ `tls.DEFAULT_ECDH_CURVE` ] : #tls_tls_default_ecdh_curve
15451552[ `tls.Server` ] : #tls_class_tls_server
15461553[ `tls.TLSSocket.getPeerCertificate()` ] : #tls_tlssocket_getpeercertificate_detailed
Original file line number Diff line number Diff line change @@ -1256,6 +1256,11 @@ exports.connect = function connect(...args) {
12561256 localAddress : options . localAddress ,
12571257 lookup : options . lookup
12581258 } ;
1259+
1260+ if ( options . timeout ) {
1261+ tlssock . setTimeout ( options . timeout ) ;
1262+ }
1263+
12591264 tlssock . connect ( connectOpt , tlssock . _start ) ;
12601265 }
12611266
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const common = require ( '../common' ) ;
4+
5+ // This test verifies that `tls.connect()` honors the `timeout` option when the
6+ // socket is internally created.
7+
8+ if ( ! common . hasCrypto )
9+ common . skip ( 'missing crypto' ) ;
10+
11+ const assert = require ( 'assert' ) ;
12+ const tls = require ( 'tls' ) ;
13+
14+ const socket = tls . connect ( {
15+ lookup : ( ) => { } ,
16+ timeout : 1000
17+ } ) ;
18+
19+ assert . strictEqual ( socket . timeout , 1000 ) ;
You can’t perform that action at this time.
0 commit comments