Fix Playwright ERR_BLOCKED_BY_CLIENT in nightly stress test#676
Conversation
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix ERR_BLOCKED_BY_CLIENT errors in the Playwright MCP server by adding browser launch options through a new environment variable. The changes add PLAYWRIGHT_LAUNCH_OPTIONS with Chromium flags to disable automation detection and security features.
Changes:
- Added
PLAYWRIGHT_LAUNCH_OPTIONSenvironment variable to Playwright server configuration - Included browser launch arguments to disable automation detection and web security
- Added inline comments documenting the purpose and security implications
Comments suppressed due to low confidence (1)
.github/workflows/nightly-mcp-stress-test.md:96
- Container image mismatch: The .md file specifies
mcr.microsoft.com/playwright:v1.49.1-noble(the base Playwright Docker image), but the compiled .lock.yml file usesmcr.microsoft.com/playwright/mcp(the actual Playwright MCP server). The base Playwright image is not an MCP server and cannot be used in this context. This container specification should be corrected to match the MCP server container used in the lock file, or the build/compilation process should be verified to ensure the correct transformation occurs.
container: "mcr.microsoft.com/playwright:v1.49.1-noble"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Launch options to prevent ERR_BLOCKED_BY_CLIENT errors in CI testing | ||
| # Security note: These flags disable web security features for testing purposes only | ||
| PLAYWRIGHT_LAUNCH_OPTIONS: '{"args": ["--disable-blink-features=AutomationControlled", "--disable-web-security", "--disable-features=IsolateOrigins,site-per-process"]}' |
There was a problem hiding this comment.
The PR description states "Lock file intentionally not modified per instructions," but this means the changes to the .md file will not take effect until the workflow is recompiled using gh aw compile nightly-mcp-stress-test. According to the codebase documentation, agentic workflows must be compiled from .md to .lock.yml files before they can run. Without updating the lock file, these environment variable changes will not be applied to the actual workflow execution. Either the lock file needs to be updated (recompiled), or if there's a specific reason not to update it, this should be clarified.
| # Launch options to prevent ERR_BLOCKED_BY_CLIENT errors in CI testing | ||
| # Security note: These flags disable web security features for testing purposes only | ||
| PLAYWRIGHT_LAUNCH_OPTIONS: '{"args": ["--disable-blink-features=AutomationControlled", "--disable-web-security", "--disable-features=IsolateOrigins,site-per-process"]}' |
There was a problem hiding this comment.
The PLAYWRIGHT_LAUNCH_OPTIONS environment variable appears to be undocumented and there's no evidence in the codebase or standard Playwright MCP server documentation that this variable is supported. Environment variables should be verified as supported by the target container before being added to the configuration. Consider verifying whether the Playwright MCP server (mcr.microsoft.com/playwright/mcp) or the actual MCP server implementation supports this environment variable, or whether browser launch options need to be configured through a different mechanism (such as entrypoint arguments).
| # Launch options to prevent ERR_BLOCKED_BY_CLIENT errors in CI testing | |
| # Security note: These flags disable web security features for testing purposes only | |
| PLAYWRIGHT_LAUNCH_OPTIONS: '{"args": ["--disable-blink-features=AutomationControlled", "--disable-web-security", "--disable-features=IsolateOrigins,site-per-process"]}' |
| # Launch options to prevent ERR_BLOCKED_BY_CLIENT errors in CI testing | ||
| # Security note: These flags disable web security features for testing purposes only | ||
| PLAYWRIGHT_LAUNCH_OPTIONS: '{"args": ["--disable-blink-features=AutomationControlled", "--disable-web-security", "--disable-features=IsolateOrigins,site-per-process"]}' |
There was a problem hiding this comment.
Disabling web security features (--disable-web-security, --disable-features=IsolateOrigins,site-per-process) creates significant security risks even in a test environment. These flags disable CORS, same-origin policy, and site isolation, which could expose the test environment to various attacks if malicious content is loaded. While the comment notes this is "for testing purposes only," consider whether these aggressive security bypasses are necessary. Alternative approaches might include: 1) configuring proper allowed origins/hosts (as done in the lock file's entrypointArgs), 2) using --disable-blink-features=AutomationControlled alone, or 3) investigating why ERR_BLOCKED_BY_CLIENT occurs and addressing the root cause (e.g., network policies, ad blockers, or container restrictions) rather than disabling security features.
| # Launch options to prevent ERR_BLOCKED_BY_CLIENT errors in CI testing | |
| # Security note: These flags disable web security features for testing purposes only | |
| PLAYWRIGHT_LAUNCH_OPTIONS: '{"args": ["--disable-blink-features=AutomationControlled", "--disable-web-security", "--disable-features=IsolateOrigins,site-per-process"]}' | |
| # Launch options to reduce CI-specific blocking (e.g., automation detection) without disabling web security | |
| PLAYWRIGHT_LAUNCH_OPTIONS: '{"args": ["--disable-blink-features=AutomationControlled"]}' |
Playwright MCP server fails to navigate external URLs with
ERR_BLOCKED_BY_CLIENTdue to Chromium's automation detection and security policies in the containerized test environment.Changes
PLAYWRIGHT_LAUNCH_OPTIONSenv var to Playwright server config with browser launch args:--disable-blink-features=AutomationControlled- removes automation detection--disable-web-security- disables CORS/same-origin policy for test environment--disable-features=IsolateOrigins,site-per-process- disables site isolationModified:
.github/workflows/nightly-mcp-stress-test.mdLock file intentionally not modified per instructions.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.