File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common' ) ;
3
+
4
+ if ( ! common . hasCrypto )
5
+ common . skip ( 'missing crypto' ) ;
6
+
7
+ const fixtures = require ( '../common/fixtures' ) ;
8
+ const https = require ( 'https' ) ;
9
+ const assert = require ( 'assert' ) ;
10
+ const { once } = require ( 'events' ) ;
11
+
12
+ const options = {
13
+ key : fixtures . readKey ( 'agent1-key.pem' ) ,
14
+ cert : fixtures . readKey ( 'agent1-cert.pem' )
15
+ } ;
16
+
17
+ ( async ( ) => {
18
+ const { port, server } = await new Promise ( ( resolve ) => {
19
+ const server = https . createServer ( options , ( ) => { } ) ;
20
+ server . listen ( 0 , ( ) => resolve ( { port : server . address ( ) . port , server } ) ) ;
21
+ } ) ;
22
+ try {
23
+ const ac = new AbortController ( ) ;
24
+ const req = https . request ( {
25
+ host : 'localhost' ,
26
+ port,
27
+ path : '/' ,
28
+ method : 'GET' ,
29
+ rejectUnauthorized : false ,
30
+ signal : ac . signal ,
31
+ } ) ;
32
+ process . nextTick ( ( ) => ac . abort ( ) ) ;
33
+ const [ err ] = await once ( req , 'error' ) ;
34
+ assert . strictEqual ( err . name , 'AbortError' ) ;
35
+ assert . strictEqual ( err . code , 'ABORT_ERR' ) ;
36
+ } finally {
37
+ server . close ( ) ;
38
+ }
39
+ } ) ( ) . then ( common . mustCall ( ) ) ;
You can’t perform that action at this time.
0 commit comments