node/test/parallel/test-tls-connect-timeout-option.js
Denys Otrishko 78ca61e2cf net: check args in net.connect() and socket.connect() calls
Previously Node.js would handle empty `net.connect()` and
`socket.connect()` call as if the user passed empty options object which
doesn't really make sense. This was due to the fact that it uses the
same `normalizeArgs` function as `.listen()` call where such call is
perfectly fine.

This will make it clear what is the problem with such call and how it
can be resolved. It now throws `ERR_MISSING_ARGS` if no arguments were
passed or neither `path` nor `port` is specified.

Fixes: https://github.com/nodejs/node/issues/33930

PR-URL: https://github.com/nodejs/node/pull/34022
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
2020-06-24 14:45:10 -07:00

21 lines
411 B
JavaScript

'use strict';
const common = require('../common');
// This test verifies that `tls.connect()` honors the `timeout` option when the
// socket is internally created.
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const tls = require('tls');
const socket = tls.connect({
port: 42,
lookup: () => {},
timeout: 1000
});
assert.strictEqual(socket.timeout, 1000);