@@ -347,27 +347,31 @@ export class McpContext implements Context {
347347 const mcpPage = this . #getMcpPage( page ) ;
348348 const newSettings : EmulationSettings = { ...mcpPage . emulationSettings } ;
349349
350- // Skip network emulation if blocklist/allowlist is configured, as it is rejected by Puppeteer.
351- if ( ! this . #options. hasNetworkBlockOrAllowlist ) {
352- if ( ! options . networkConditions ) {
353- await page . emulateNetworkConditions ( null ) ;
354- delete newSettings . networkConditions ;
355- } else if ( options . networkConditions === 'Offline' ) {
356- await page . emulateNetworkConditions ( {
357- offline : true ,
358- download : 0 ,
359- upload : 0 ,
360- latency : 0 ,
361- } ) ;
362- newSettings . networkConditions = 'Offline' ;
363- } else if ( options . networkConditions in PredefinedNetworkConditions ) {
364- const networkCondition =
365- PredefinedNetworkConditions [
366- options . networkConditions as keyof typeof PredefinedNetworkConditions
367- ] ;
368- await page . emulateNetworkConditions ( networkCondition ) ;
369- newSettings . networkConditions = options . networkConditions ;
350+ // Skip network emulation if blocklist/allowlist is configured, as it conflicts with blocking rules in Puppeteer.
351+ if ( this . #options. hasNetworkBlockOrAllowlist ) {
352+ if ( options . networkConditions !== undefined ) {
353+ throw new Error (
354+ 'Network throttling is not supported when network blocking (allowlist/blocklist) is configured.' ,
355+ ) ;
370356 }
357+ } else if ( ! options . networkConditions ) {
358+ await page . emulateNetworkConditions ( null ) ;
359+ delete newSettings . networkConditions ;
360+ } else if ( options . networkConditions === 'Offline' ) {
361+ await page . emulateNetworkConditions ( {
362+ offline : true ,
363+ download : 0 ,
364+ upload : 0 ,
365+ latency : 0 ,
366+ } ) ;
367+ newSettings . networkConditions = 'Offline' ;
368+ } else if ( options . networkConditions in PredefinedNetworkConditions ) {
369+ const networkCondition =
370+ PredefinedNetworkConditions [
371+ options . networkConditions as keyof typeof PredefinedNetworkConditions
372+ ] ;
373+ await page . emulateNetworkConditions ( networkCondition ) ;
374+ newSettings . networkConditions = options . networkConditions ;
371375 }
372376
373377 const secondarySession = this . getDevToolsUniverse ( mcpPage ) ?. session ;
0 commit comments