node: sync test-net-connect-options-invalid.js (#20607)

This commit is contained in:
Meghan Denny
2025-06-24 21:46:56 -08:00
committed by GitHub
parent 3f257a2905
commit 4cf31f6a57
2 changed files with 15 additions and 0 deletions

View File

@@ -1514,6 +1514,8 @@ function lookupAndConnect(self, options) {
const host = options.host || "localhost";
let { port, autoSelectFamilyAttemptTimeout, autoSelectFamily } = options;
validateString(host, "options.host");
if (localAddress && !isIP(localAddress)) {
throw $ERR_INVALID_IP_ADDRESS(localAddress);
}

View File

@@ -25,3 +25,16 @@ const net = require('net');
});
});
}
{
assert.throws(() => {
net.createConnection({
host: ['192.168.0.1'],
port: 8080,
});
}, {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "options.host" property must be of type string. Received an instance of Array',
});
}