File tree 1 file changed +19
-21
lines changed
1 file changed +19
-21
lines changed Original file line number Diff line number Diff line change 3
3
// just like test-gc-http-client.js,
4
4
// but aborting every connection that comes in.
5
5
6
- require ( '../common' ) ;
6
+ const common = require ( '../common' ) ;
7
7
const onGC = require ( '../common/ongc' ) ;
8
8
9
- function serverHandler ( req , res ) {
10
- res . connection . destroy ( ) ;
11
- }
12
-
13
9
const http = require ( 'http' ) ;
14
10
const todo = 500 ;
15
11
let done = 0 ;
@@ -18,33 +14,35 @@ let countGC = 0;
18
14
19
15
console . log ( `We should do ${ todo } requests` ) ;
20
16
17
+ function serverHandler ( req , res ) {
18
+ res . connection . destroy ( ) ;
19
+ }
20
+
21
21
const server = http . createServer ( serverHandler ) ;
22
- server . listen ( 0 , getall ) ;
22
+ server . listen ( 0 , common . mustCall ( ( ) => {
23
+ for ( let i = 0 ; i < 10 ; i ++ )
24
+ getall ( ) ;
25
+ } ) ) ;
23
26
24
27
function getall ( ) {
25
28
if ( count >= todo )
26
29
return ;
27
30
28
- ( function ( ) {
29
- function cb ( res ) {
30
- done += 1 ;
31
- }
31
+ const req = http . get ( {
32
+ hostname : 'localhost' ,
33
+ pathname : '/' ,
34
+ port : server . address ( ) . port
35
+ } , cb ) . on ( 'error' , cb ) ;
32
36
33
- const req = http . get ( {
34
- hostname : 'localhost' ,
35
- pathname : '/' ,
36
- port : server . address ( ) . port
37
- } , cb ) . on ( 'error' , cb ) ;
38
-
39
- count ++ ;
40
- onGC ( req , { ongc } ) ;
41
- } ) ( ) ;
37
+ count ++ ;
38
+ onGC ( req , { ongc } ) ;
42
39
43
40
setImmediate ( getall ) ;
44
41
}
45
42
46
- for ( let i = 0 ; i < 10 ; i ++ )
47
- getall ( ) ;
43
+ function cb ( res ) {
44
+ done += 1 ;
45
+ }
48
46
49
47
function ongc ( ) {
50
48
countGC ++ ;
You can’t perform that action at this time.
0 commit comments