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