Skip to content

fix(mcp): preserve HAR recordings from isolated contexts - #44212

Closed
microsoft-playwright-automation[bot] wants to merge 2 commits into
mainfrom
fix-44199-44350195101-1
Closed

microsoft-playwright-automation[bot] wants to merge 2 commits into
mainfrom
fix-44199-44350195101-1

Conversation

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor

Isolated contexts inherited the default context's HAR path, so their recordings overwrote each other and were then overwritten by the default context on close.

Keep the configured path for the default context and save each isolated context beside it, with its sanitized name before the extension. Reuse output-file numbering to avoid collisions and document the naming rule. The existing isolated-tab test now checks the HAR requests from the default context and two isolated contexts.

Fixes #44199

Verified on Windows: the regression fails without the fix and passes on Chromium, Firefox and WebKit. Related MCP tests: 125 passed, 10 skipped. Build and full lint passed.

Triaged on Windows by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

🟢 All three failures also occur on the base commit

I'm the Playwright bot. These failures were not caused by this PR.

Details

Checked the MCP run for head 708c420897f2dbf834c75c69d419e18e27b49654. The PR changes HAR filenames for named isolated contexts; the failing tests use the default context and do not reach that code.

Pre-existing flake / infra

All three [chrome] failures in mcp/crash.spec.ts also occur in the Ubuntu Chrome job on main, at this PR's base commit d456688ec2c9fbcbc4a8515afb901fabdcf1a136:

  • :31 — reports the navigation error, then resets and logs the crash: the same 30-second timeout at toPass() on line 48.
  • :58 — lists only one tab: the same 30-second timeout and Not connected at browser_tabs on line 71.
  • :79 — marks non-current crashed tab in the tab list: the same 30-second timeout and Not connected at browser_tabs on line 93.

This proves the failures predate the PR; it does not establish whether they are intermittent. No PR change is needed for these failures.

Checked the failures on Linux by the Playwright bot - agent run

@dcrousso
Devin Rousso (dcrousso) marked this pull request as ready for review November 18, 2026 20:43

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should change the config here. We should suggest that user starts / stops tracing instead, trace contains HAR. We can also implement start / stop har feature.

@microsoft-playwright-automation

This comment has been minimized.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

Hi, I'm the Playwright bot. I removed the HAR filename changes as requested.

Pavel Feldman (@pavelfeldman): HAR configuration and context creation now match main. The tracing guide recommends browser_start_tracing / browser_stop_tracing with --caps=devtools to save separate network logs for isolated contexts. These logs contain HAR request and response data, but are not standalone .har files. I did not add a new start/stop HAR API.

The existing tracing test now checks that the default and isolated contexts' requests remain in their separate network logs after close. On Windows, the tracing and related tests passed on Chromium, Firefox and WebKit: 151 passed, 2 skipped. Build and full lint passed. The original shared-HAR-path behavior remains unchanged.

@microsoft-playwright-automation microsoft-playwright-automation Bot added agent-review-done The Playwright bot run ended and removed agent-review labels Nov 20, 2026
@dcrousso

Copy link
Copy Markdown
Contributor

closing per #44199 (comment)

@dcrousso
Devin Rousso (dcrousso) deleted the fix-44199-44350195101-1 branch November 20, 2026 21:45
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

5250 passed, 644 skipped


Merge workflow run.

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

Labels

agent-review-done The Playwright bot run ended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MCP]: Tabs opened with isolatedContext are missing from the HAR set by contextOptions.recordHar

2 participants