@@ -9,9 +9,10 @@ const common = require('../common');
99if ( ! common . hasCrypto )
1010 common . skip ( 'missing crypto' ) ;
1111const http2 = require ( 'http2' ) ;
12- const { PassThrough } = require ( 'stream ' ) ;
12+ const makeDuplexPair = require ( '../common/duplexpair ' ) ;
1313
1414const server = http2 . createServer ( ) ;
15+ const { clientSide, serverSide } = makeDuplexPair ( ) ;
1516
1617// 'session' event should be emitted 3 times:
1718// - the vanilla client
@@ -25,22 +26,28 @@ server.listen(0, common.mustCall(() => {
2526 const port = server . address ( ) . port ;
2627
2728 // unref new client
28- let client = http2 . connect ( `http://localhost:${ port } ` ) ;
29- client . unref ( ) ;
29+ {
30+ const client = http2 . connect ( `http://localhost:${ port } ` ) ;
31+ client . unref ( ) ;
32+ }
3033
3134 // unref destroyed client
32- client = http2 . connect ( `http://localhost:${ port } ` ) ;
33- client . destroy ( ) ;
34- client . unref ( ) ;
35-
36- // unref client with generic Duplex stream
37- client = http2 . connect ( `http://localhost:${ port } ` , {
38- createConnection : common . mustCall ( ( ) => PassThrough ( ) )
39- } ) ;
40- client . unref ( ) ;
35+ {
36+ const client = http2 . connect ( `http://localhost:${ port } ` ) ;
37+ client . destroy ( ) ;
38+ client . unref ( ) ;
39+ }
40+
41+ // unref destroyed client
42+ {
43+ const client = http2 . connect ( `http://localhost:${ port } ` , {
44+ createConnection : common . mustCall ( ( ) => clientSide )
45+ } ) ;
46+ client . destroy ( ) ;
47+ client . unref ( ) ;
48+ }
4149} ) ) ;
50+ server . emit ( 'connection' , serverSide ) ;
4251server . unref ( ) ;
4352
44- server . emit ( 'connection' , PassThrough ( ) ) ;
45-
4653setTimeout ( common . mustNotCall ( ( ) => { } ) , 1000 ) . unref ( ) ;
0 commit comments