mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00

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>
32 lines
865 B
JavaScript
32 lines
865 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// This test verifies that `tls.connect()` honors the `hints` option.
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const dns = require('dns');
|
|
const tls = require('tls');
|
|
|
|
const hints = 512;
|
|
|
|
assert.notStrictEqual(hints, dns.ADDRCONFIG);
|
|
assert.notStrictEqual(hints, dns.V4MAPPED);
|
|
assert.notStrictEqual(hints, dns.ALL);
|
|
assert.notStrictEqual(hints, dns.ADDRCONFIG | dns.V4MAPPED);
|
|
assert.notStrictEqual(hints, dns.ADDRCONFIG | dns.ALL);
|
|
assert.notStrictEqual(hints, dns.V4MAPPED | dns.ALL);
|
|
assert.notStrictEqual(hints, dns.ADDRCONFIG | dns.V4MAPPED | dns.ALL);
|
|
|
|
tls.connect({
|
|
port: 42,
|
|
lookup: common.mustCall((host, options) => {
|
|
assert.strictEqual(host, 'localhost');
|
|
assert.deepStrictEqual(options, { family: undefined, hints });
|
|
}),
|
|
hints
|
|
});
|