@@ -28,7 +28,7 @@ import {
28
28
type RequestConfigWithMeta ,
29
29
HttpClientLogLevel ,
30
30
} from "../logging/types" ;
31
- import { serializeValue , sizeOf } from "../logging/utils" ;
31
+ import { sizeOf } from "../logging/utils" ;
32
32
import { WsLogger } from "../logging/wsLogger" ;
33
33
import {
34
34
OneWayWebSocket ,
@@ -261,7 +261,7 @@ function wrapRequestTransform(
261
261
? transformer
262
262
: [ transformer ] ;
263
263
264
- // Transform the request first then estimate the size
264
+ // Transform the request first then get the size (measure what's sent over the wire)
265
265
const result = transformerArray . reduce (
266
266
( d , fn ) => fn . call ( config , d , headers ) ,
267
267
data ,
@@ -280,7 +280,7 @@ function wrapResponseTransform(
280
280
) : AxiosResponseTransformer [ ] {
281
281
return [
282
282
( data : unknown , headers : AxiosResponseHeaders , status ?: number ) => {
283
- // estimate the size before transforming the response
283
+ // Get the size before transforming the response (measure what's sent over the wire)
284
284
config . rawResponseSize = getSize ( headers , data ) ;
285
285
286
286
const transformerArray = Array . isArray ( transformer )
@@ -301,14 +301,7 @@ function getSize(headers: AxiosHeaders, data: unknown): number | undefined {
301
301
return parseInt ( contentLength , 10 ) ;
302
302
}
303
303
304
- const size = sizeOf ( data ) ;
305
- if ( size !== undefined ) {
306
- return size ;
307
- }
308
-
309
- // Fallback
310
- const stringified = serializeValue ( data ) ;
311
- return stringified === null ? undefined : Buffer . byteLength ( stringified ) ;
304
+ return sizeOf ( data ) ;
312
305
}
313
306
314
307
function getLogLevel ( ) : HttpClientLogLevel {
0 commit comments