@@ -467,6 +467,13 @@ async function saveResponseResource(network, request, session) {
467467 url,
468468 responseStatus : response ?. status
469469 } ;
470+ // Checing for content length more than 100MB, to prevent websocket error which is governed by
471+ // maxPayload option of websocket defaulted to 100MB.
472+ // If content-length is more than our allowed 25MB, no need to process that resouce we can return log.
473+ let contentLength = parseInt ( response . headers [ 'Content-Length' ] ) ;
474+ if ( contentLength > MAX_RESOURCE_SIZE ) {
475+ return log . debug ( '- Skipping resource larger than 25MB' , meta ) ;
476+ }
470477 let resource = network . intercept . getResource ( url ) ;
471478
472479 if ( ! resource || ( ! resource . root && ! resource . provided && disableCache ) ) {
@@ -484,8 +491,6 @@ async function saveResponseResource(network, request, session) {
484491 return log . debug ( '- Skipping remote resource' , meta ) ;
485492 } else if ( ! body . length ) {
486493 return log . debug ( '- Skipping empty response' , meta ) ;
487- } else if ( body . length > MAX_RESOURCE_SIZE ) {
488- return log . debug ( '- Skipping resource larger than 25MB' , meta ) ;
489494 } else if ( ! ALLOWED_STATUSES . includes ( response . status ) ) {
490495 return log . debug ( `- Skipping disallowed status [${ response . status } ]` , meta ) ;
491496 } else if ( ! enableJavaScript && ! ALLOWED_RESOURCES . includes ( request . type ) ) {
0 commit comments