There is no need to try to create a TCP connection that fails due to a missing listening server. Also, the port used for the connection might be used by another process when the connection is made. PR-URL: https://github.com/nodejs/node/pull/57144 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
23 lines
473 B
JavaScript
23 lines
473 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const assert = require('assert');
|
|
const http2 = require('http2');
|
|
const util = require('util');
|
|
|
|
const connect = util.promisify(http2.connect);
|
|
|
|
const error = new Error('Unable to resolve hostname');
|
|
|
|
function lookup(hostname, options, callback) {
|
|
callback(error);
|
|
}
|
|
|
|
assert.rejects(
|
|
connect('http://hostname', { lookup }),
|
|
error,
|
|
).then(common.mustCall());
|