File tree Expand file tree Collapse file tree 1 file changed +19
-21
lines changed Expand file tree Collapse file tree 1 file changed +19
-21
lines changed Original file line number Diff line number Diff line change 33// just like test-gc-http-client.js,
44// but aborting every connection that comes in.
55
6- require ( '../common' ) ;
6+ const common = require ( '../common' ) ;
77const onGC = require ( '../common/ongc' ) ;
88
9- function serverHandler ( req , res ) {
10- res . connection . destroy ( ) ;
11- }
12-
139const http = require ( 'http' ) ;
1410const todo = 500 ;
1511let done = 0 ;
@@ -18,33 +14,35 @@ let countGC = 0;
1814
1915console . log ( `We should do ${ todo } requests` ) ;
2016
17+ function serverHandler ( req , res ) {
18+ res . connection . destroy ( ) ;
19+ }
20+
2121const 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+ } ) ) ;
2326
2427function getall ( ) {
2528 if ( count >= todo )
2629 return ;
2730
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 ) ;
3236
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 } ) ;
4239
4340 setImmediate ( getall ) ;
4441}
4542
46- for ( let i = 0 ; i < 10 ; i ++ )
47- getall ( ) ;
43+ function cb ( res ) {
44+ done += 1 ;
45+ }
4846
4947function ongc ( ) {
5048 countGC ++ ;
You can’t perform that action at this time.
0 commit comments