File tree Expand file tree Collapse file tree
src/HttpClient/middlewares Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,28 +92,22 @@ export const requestMiddleware = (limit?: Limit) => async (ctx: MiddlewareContex
9292 ctx . response = await ( limit ? limit ( makeRequest ) : makeRequest ( ) )
9393}
9494
95- function countPerOrigin ( obj : { [ key : string ] : any [ ] } ) {
95+ function count ( obj : { [ key : string ] : any [ ] } ) {
9696 try {
97- return mapObjIndexed ( val => val . length , obj )
97+ return Object . values ( obj ) . reduce ( ( acc , val ) => acc += val . length , 0 )
9898 } catch ( _ ) {
99- return { }
99+ return 0
100100 }
101101}
102102
103103export function httpAgentStats ( ) {
104- const socketsPerOrigin = countPerOrigin ( httpAgent . sockets )
105- const sockets = sum ( values ( socketsPerOrigin ) )
106- const freeSocketsPerOrigin = countPerOrigin ( ( httpAgent as any ) . freeSockets )
107- const freeSockets = sum ( values ( freeSocketsPerOrigin ) )
108- const pendingRequestsPerOrigin = countPerOrigin ( httpAgent . requests )
109- const pendingRequests = sum ( values ( pendingRequestsPerOrigin ) )
104+ const sockets = count ( httpAgent . sockets )
105+ const freeSockets = count ( ( httpAgent as any ) . freeSockets )
106+ const pendingRequests = count ( httpAgent . requests )
110107
111108 return {
112109 freeSockets,
113- freeSocketsPerOrigin,
114110 pendingRequests,
115- pendingRequestsPerOrigin,
116111 sockets,
117- socketsPerOrigin,
118112 }
119113}
You can’t perform that action at this time.
0 commit comments