forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: reject failed http2.connect when used with promisify
PR-URL: nodejs#53475 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
- Loading branch information
Showing
2 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/parallel/test-http2-client-promisify-connect-error.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
})); | ||
}); | ||
})); |