@@ -66,6 +66,26 @@ const httpKeepAliveOptions = {
66
66
} )
67
67
}
68
68
69
+ const axiosAgent = new http . Agent ( {
70
+ keepAlive : true ,
71
+ maxSockets : connections
72
+ } )
73
+
74
+ const fetchAgent = new http . Agent ( {
75
+ keepAlive : true ,
76
+ maxSockets : connections
77
+ } )
78
+
79
+ const gotAgent = new http . Agent ( {
80
+ keepAlive : true ,
81
+ maxSockets : connections
82
+ } )
83
+
84
+ const requestAgent = new http . Agent ( {
85
+ keepAlive : true ,
86
+ maxSockets : connections
87
+ } )
88
+
69
89
const undiciOptions = {
70
90
path : '/' ,
71
91
method : 'GET' ,
@@ -280,7 +300,7 @@ if (process.env.PORT) {
280
300
281
301
experiments [ 'node-fetch' ] = ( ) => {
282
302
return makeParallelRequests ( resolve => {
283
- nodeFetch ( dest . url ) . then ( res => {
303
+ nodeFetch ( dest . url , { agent : fetchAgent } ) . then ( res => {
284
304
res . body . pipe ( new Writable ( {
285
305
write ( chunk , encoding , callback ) {
286
306
callback ( )
@@ -292,7 +312,7 @@ if (process.env.PORT) {
292
312
293
313
experiments . axios = ( ) => {
294
314
return makeParallelRequests ( resolve => {
295
- axios . get ( dest . url , { responseType : 'stream' } ) . then ( res => {
315
+ axios . get ( dest . url , { responseType : 'stream' , httpAgent : axiosAgent } ) . then ( res => {
296
316
res . data . pipe ( new Writable ( {
297
317
write ( chunk , encoding , callback ) {
298
318
callback ( )
@@ -304,7 +324,7 @@ if (process.env.PORT) {
304
324
305
325
experiments . got = ( ) => {
306
326
return makeParallelRequests ( resolve => {
307
- got . get ( dest . url ) . then ( res => {
327
+ got . get ( dest . url , null , { http : gotAgent } ) . then ( res => {
308
328
res . pipe ( new Writable ( {
309
329
write ( chunk , encoding , callback ) {
310
330
callback ( )
@@ -316,7 +336,7 @@ if (process.env.PORT) {
316
336
317
337
experiments . request = ( ) => {
318
338
return makeParallelRequests ( resolve => {
319
- request ( dest . url ) . then ( res => {
339
+ request ( dest . url , { agent : requestAgent } ) . then ( res => {
320
340
res . pipe ( new Writable ( {
321
341
write ( chunk , encoding , callback ) {
322
342
callback ( )
0 commit comments