Skip to content

fix(cli): persist traces when CLI attaches to existing CDP browser#40810

Merged
yury-s merged 2 commits into
microsoft:mainfrom
yury-s:fix-378
May 13, 2026
Merged

fix(cli): persist traces when CLI attaches to existing CDP browser#40810
yury-s merged 2 commits into
microsoft:mainfrom
yury-s:fix-378

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented May 12, 2026

Summary

  • Add optional `artifactsDir` to `BrowserType.connectOverCDP` so the caller controls where trace and download files land.
  • Wire the MCP browser factory to pass the computed traces directory so CLI `tracing-start`/`tracing-stop` over `attach --cdp=...` write files to the advertised paths instead of a temp dir.

Fixes microsoft/playwright-cli#378

The MCP browser_start_tracing tool advertised trace files under
`.playwright-cli/traces/`, but for CDP-attached browsers the underlying
server used an auto-created temp `artifactsDir`, so trace files never
appeared at the advertised paths.

Add an optional `artifactsDir` parameter to `BrowserType.connectOverCDP`
and have the MCP browser factory pass the desired directory through. The
server uses the supplied directory directly (creating it if missing) and
skips cleanup on disconnect when the directory was provided by the caller.

Fixes: microsoft/playwright-cli#378
@github-actions

This comment has been minimized.

The client's _wrapApiCall prepends the API frame name to error
messages, so the actual error is "Error: async initializeServer:
connect ECONNREFUSED ..." rather than "Error: connect ECONNREFUSED ...".
Match on the underlying socket error substring instead.
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

6 failed
❌ [chromium] › mcp/annotate.spec.ts:137 › should abort MCP annotation when last screenshot is removed @mcp-windows-latest-chromium
❌ [chromium] › mcp/annotate.spec.ts:330 › should annotate when context has no fixed viewport @mcp-windows-latest-chromium
❌ [chromium] › mcp/annotate.spec.ts:367 › should cancel browser_annotate when the MCP request is aborted @mcp-windows-latest-chromium
❌ [firefox] › mcp/cli-devtools.spec.ts:217 › video-start-stop @mcp-windows-latest-firefox
❌ [firefox] › mcp/cli-devtools.spec.ts:231 › video-chapter @mcp-windows-latest-firefox
❌ [msedge] › mcp/annotate.spec.ts:398 › should cancel browser_annotate when the MCP client disconnects @mcp-windows-latest-msedge

7071 passed, 1074 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests 1"

3 flaky ⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@chromium-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/inspector/cli-codegen-3.spec.ts:224 › cli codegen › should generate frame locators (4) `@firefox-ubuntu-22.04-node20`

41769 passed, 850 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] trace still not working same as #230

2 participants