@@ -28,7 +28,7 @@ import {
2828 type RequestConfigWithMeta ,
2929 HttpClientLogLevel ,
3030} from "../logging/types" ;
31- import { serializeValue , sizeOf } from "../logging/utils" ;
31+ import { sizeOf } from "../logging/utils" ;
3232import { WsLogger } from "../logging/wsLogger" ;
3333import {
3434 OneWayWebSocket ,
@@ -261,7 +261,7 @@ function wrapRequestTransform(
261261 ? transformer
262262 : [ transformer ] ;
263263
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)
265265 const result = transformerArray . reduce (
266266 ( d , fn ) => fn . call ( config , d , headers ) ,
267267 data ,
@@ -280,7 +280,7 @@ function wrapResponseTransform(
280280) : AxiosResponseTransformer [ ] {
281281 return [
282282 ( 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)
284284 config . rawResponseSize = getSize ( headers , data ) ;
285285
286286 const transformerArray = Array . isArray ( transformer )
@@ -301,14 +301,7 @@ function getSize(headers: AxiosHeaders, data: unknown): number | undefined {
301301 return parseInt ( contentLength , 10 ) ;
302302 }
303303
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 ) ;
312305}
313306
314307function getLogLevel ( ) : HttpClientLogLevel {
0 commit comments