diff --git a/AGENTS.md b/AGENTS.md index ad18865..a3eb98d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -67,7 +67,7 @@ NEVER call browser.close() in tests or any other code that interacts with our CD remember that every time the extension is activated in a tab that tab gets added to the available pages. so if you toggle the extension and then do .newPage() there will be 2 pages, not 1. -to debug server or extension issues you can also inspect the file @playwriter/relay-server.log to see both extension and server logs. with all cdp events sent. to see if there are events missing or something broken. this file is recreated every time the server is started and appended in real time. use rg to only read relevant lines and parts because it can get quite long +to debug server or extension issues you can inspect the relay server log file. run `playwriter logfile` to get the path (it's in the system temp directory, e.g. `/tmp/playwriter/relay-server.log` on Linux/macOS). this file contains logs from the extension, MCP and WS server together, with all CDP events. the file is recreated every time the server starts and appended in real time. use rg to only read relevant lines because it can get quite long IMPORTANT: `pnpm test` will take about 1 minute or more so set a timeout of at least 90000ms when running the pnpm test bash command diff --git a/PLAYWRITER_AGENTS.md b/PLAYWRITER_AGENTS.md index a254e0b..d6d6f63 100644 --- a/PLAYWRITER_AGENTS.md +++ b/PLAYWRITER_AGENTS.md @@ -65,7 +65,7 @@ NEVER call browser.close() in tests or any other code that interacts with our CD remember that every time the extension is activated in a tab that tab gets added to the available pages. so if you toggle the extension and then do .newPage() there will be 2 pages, not 1. -to debug server or extension issues you can also inspect the file @playwriter/relay-server.log to see both extension and server logs. with all cdp events sent. to see if there are events missing or something broken. this file is recreated every time the server is started and appended in real time. use rg to only read relevant lines and parts because it can get quite long +to debug server or extension issues you can inspect the relay server log file. run `playwriter logfile` to get the path (it's in the system temp directory, e.g. `/tmp/playwriter/relay-server.log` on Linux/macOS). this file contains logs from the extension, MCP and WS server together, with all CDP events. the file is recreated every time the server starts and appended in real time. use rg to only read relevant lines because it can get quite long IMPORTANT: `pnpm test` will take about 1 minute or more so set a timeout of at least 90000ms when running the pnpm test bash command diff --git a/README.md b/README.md index 206507b..51037a2 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,17 @@ npx -y playwriter serve --host 127.0.0.1 const browser = await chromium.connectOverCDP('http://127.0.0.1:19988') ``` +## Troubleshooting + +View relay server logs to debug issues: + +```bash +playwriter logfile # prints the log file path +# typically: /tmp/playwriter/relay-server.log (Linux/macOS) +``` + +The log file contains extension, MCP and WebSocket server logs with all CDP events. It's recreated on each server start. + ## Known Issues - If all pages return `about:blank`, restart Chrome (Chrome bug in `chrome.debugger` API) diff --git a/playwriter/src/cli.ts b/playwriter/src/cli.ts index cef9ba8..c0ab886 100644 --- a/playwriter/src/cli.ts +++ b/playwriter/src/cli.ts @@ -311,6 +311,12 @@ cli }) }) +cli + .command('logfile', 'Print the path to the relay server log file') + .action(() => { + console.log(LOG_FILE_PATH) + }) + cli.help() cli.version(VERSION) diff --git a/skills/playwriter/SKILL.md b/skills/playwriter/SKILL.md index b8dcdb9..2450e80 100644 --- a/skills/playwriter/SKILL.md +++ b/skills/playwriter/SKILL.md @@ -91,7 +91,9 @@ EOF )" ``` -# playwriter execute +--- + +# playwriter best practices Control user's Chrome browser via playwright code snippets. Prefer single-line code with semicolons between statements. If you get "extension is not connected" or "no browser tabs have Playwriter enabled" error, tell user to click the playwriter extension icon on the tab they want to control. @@ -516,4 +518,13 @@ Examples of what playwriter can do: ## debugging playwriter issues -if some internal critical error happens you can read your own relay ws logs to understand the issue, it will show logs from extension, mcp and ws server together. then you can create a gh issue using `gh issue create -R remorses/playwriter --title title --body body`. ask for user confirmation before doing this. +if some internal critical error happens you can read the relay server logs to understand the issue. the log file is located in the system temp directory: + +```bash +playwriter logfile # prints the log file path +# typically: /tmp/playwriter/relay-server.log (Linux/macOS) or %TEMP%\playwriter\relay-server.log (Windows) +``` + +the log file contains logs from the extension, MCP and WS server together with all CDP events. the file is recreated every time the server starts. for debugging internal playwriter errors, read this file with grep/rg to find relevant lines. + +if you find a bug, you can create a gh issue using `gh issue create -R remorses/playwriter --title title --body body`. ask for user confirmation before doing this. diff --git a/slop/playwright-cdp-connection.md b/slop/playwright-cdp-connection.md index 4dabe6b..3f9323e 100644 --- a/slop/playwright-cdp-connection.md +++ b/slop/playwright-cdp-connection.md @@ -389,7 +389,7 @@ If `Target.attachedToTarget` is sent with empty URL: ### Debugging empty URL issues -Check the logs at `~/.config/opencode/playwriter.log` for: +Check the relay server logs (run `playwriter logfile` to get the path) for: ``` WARNING: Target.attachedToTarget sent with empty URL WARNING: Target.attachedToTarget received with empty URL