mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
http2: reject failed http2.connect when used with promisify
PR-URL: https://github.com/nodejs/node/pull/53475 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
This commit is contained in:
1 parent
b952ee1e12
commit
42bce05ef6
2 files changed
+33
-4
No files matched your search
@@ -0,0 +1,24 @@
|
||||
'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 server = http2.createServer();
|
||||
|
||||
server.listen(0, common.mustCall(() => {
|
||||
const port = server.address().port;
|
||||
server.close(() => {
|
||||
const connect = util.promisify(http2.connect);
|
||||
connect(`http://localhost:${port}`)
|
||||
.then(common.mustNotCall('Promise should not be resolved'))
|
||||
.catch(common.mustCall((err) => {
|
||||
assert(err instanceof Error);
|
||||
assert.strictEqual(err.code, 'ECONNREFUSED');
|
||||
}));
|
||||
});
|
||||
}));
|
||||
Reference in new issue
Block a user