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`).
1023
1023
<!-- YAML
1024
1024
added: v0.11.3
1025
1025
changes:
1026
+ - version: REPLACEME
1027
+ pr-url: https://github.com/nodejs/node/pull/25517
1028
+ description: The `timeout` option is supported now.
1026
1029
- version: v8.0.0
1027
1030
pr-url: https://github.com/nodejs/node/pull/12839
1028
1031
description: The `lookup` option is supported now.
@@ -1088,6 +1091,9 @@ changes:
1088
1091
` tls.createSecureContext() ` .
1089
1092
* ` lookup ` : {Function} Custom lookup function. ** Default:**
1090
1093
[ ` 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.
1091
1097
* ...: [ ` tls.createSecureContext() ` ] [ ] options that are used if the
1092
1098
` secureContext ` option is missing, otherwise they are ignored.
1093
1099
* ` callback ` {Function}
@@ -1541,6 +1547,7 @@ where `secureSocket` has the same API as `pair.cleartext`.
1541
1547
[ `server.getTicketKeys()` ] : #tls_server_getticketkeys
1542
1548
[ `server.listen()` ] : net.html#net_server_listen
1543
1549
[ `server.setTicketKeys()` ] : #tls_server_setticketkeys_keys
1550
+ [ `socket.setTimeout(timeout)` ] : #net_socket_settimeout_timeout_callback
1544
1551
[ `tls.DEFAULT_ECDH_CURVE` ] : #tls_tls_default_ecdh_curve
1545
1552
[ `tls.Server` ] : #tls_class_tls_server
1546
1553
[ `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) {
1256
1256
localAddress : options . localAddress ,
1257
1257
lookup : options . lookup
1258
1258
} ;
1259
+
1260
+ if ( options . timeout ) {
1261
+ tlssock . setTimeout ( options . timeout ) ;
1262
+ }
1263
+
1259
1264
tlssock . connect ( connectOpt , tlssock . _start ) ;
1260
1265
}
1261
1266
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