@@ -55,6 +55,8 @@ interface McpContextOptions {
5555 experimentalIncludeAllPages ?: boolean ;
5656 // Whether CrUX data should be fetched.
5757 performanceCrux : boolean ;
58+ // Whether allowlist/blocklist is configured.
59+ hasNetworkBlockOrAllowlist ?: boolean ;
5860}
5961
6062const DEFAULT_TIMEOUT = 5_000 ;
@@ -308,24 +310,27 @@ export class McpContext implements Context {
308310 const mcpPage = this . #getMcpPage( page ) ;
309311 const newSettings : EmulationSettings = { ...mcpPage . emulationSettings } ;
310312
311- if ( ! options . networkConditions ) {
312- await page . emulateNetworkConditions ( null ) ;
313- delete newSettings . networkConditions ;
314- } else if ( options . networkConditions === 'Offline' ) {
315- await page . emulateNetworkConditions ( {
316- offline : true ,
317- download : 0 ,
318- upload : 0 ,
319- latency : 0 ,
320- } ) ;
321- newSettings . networkConditions = 'Offline' ;
322- } else if ( options . networkConditions in PredefinedNetworkConditions ) {
323- const networkCondition =
324- PredefinedNetworkConditions [
325- options . networkConditions as keyof typeof PredefinedNetworkConditions
326- ] ;
327- await page . emulateNetworkConditions ( networkCondition ) ;
328- newSettings . networkConditions = options . networkConditions ;
313+ // Skip network emulation if blocklist/allowlist is configured, as it is rejected by Puppeteer.
314+ if ( ! this . #options. hasNetworkBlockOrAllowlist ) {
315+ if ( ! options . networkConditions ) {
316+ await page . emulateNetworkConditions ( null ) ;
317+ delete newSettings . networkConditions ;
318+ } else if ( options . networkConditions === 'Offline' ) {
319+ await page . emulateNetworkConditions ( {
320+ offline : true ,
321+ download : 0 ,
322+ upload : 0 ,
323+ latency : 0 ,
324+ } ) ;
325+ newSettings . networkConditions = 'Offline' ;
326+ } else if ( options . networkConditions in PredefinedNetworkConditions ) {
327+ const networkCondition =
328+ PredefinedNetworkConditions [
329+ options . networkConditions as keyof typeof PredefinedNetworkConditions
330+ ] ;
331+ await page . emulateNetworkConditions ( networkCondition ) ;
332+ newSettings . networkConditions = options . networkConditions ;
333+ }
329334 }
330335
331336 if ( ! options . cpuThrottlingRate ) {
0 commit comments