-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #36307 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
f5e8f12
commit f44b3c1
Showing
1 changed file
with
40 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Flags: --experimental-abortcontroller | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const fixtures = require('../common/fixtures'); | ||
const https = require('https'); | ||
const assert = require('assert'); | ||
const { once } = require('events'); | ||
|
||
const options = { | ||
key: fixtures.readKey('agent1-key.pem'), | ||
cert: fixtures.readKey('agent1-cert.pem') | ||
}; | ||
|
||
(async () => { | ||
const { port, server } = await new Promise((resolve) => { | ||
const server = https.createServer(options, () => {}); | ||
server.listen(0, () => resolve({ port: server.address().port, server })); | ||
}); | ||
try { | ||
const ac = new AbortController(); | ||
const req = https.request({ | ||
host: 'localhost', | ||
port, | ||
path: '/', | ||
method: 'GET', | ||
rejectUnauthorized: false, | ||
signal: ac.signal, | ||
}); | ||
process.nextTick(() => ac.abort()); | ||
const [ err ] = await once(req, 'error'); | ||
assert.strictEqual(err.name, 'AbortError'); | ||
assert.strictEqual(err.code, 'ABORT_ERR'); | ||
} finally { | ||
server.close(); | ||
} | ||
})().then(common.mustCall()); |