Skip to content

fix(chromium): dispose worker sessions when their frame session is disposed - #42282

Merged
Yury Semikhatsky (yury-s) merged 3 commits into
microsoft:mainfrom
yury-s:fix-42278
Aug 17, 2026
Merged

Yury Semikhatsky (yury-s) merged 3 commits into
microsoft:mainfrom
yury-s:fix-42278

Conversation

@yury-s

@yury-s Yury Semikhatsky (yury-s) commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • A dedicated worker inside an out-of-process iframe gets a CDP session that is a child of the iframe's session. When the iframe target dies, the worker's Target.detachedFromTarget is delivered on the already dead iframe session and is lost, so FrameSession.dispose() left the worker session registered in the network manager and in page.workers().
  • context.unrouteAll() then sent Network.setCacheDisabled to a session the browser had forgotten. The error reply for an unknown session carries no sessionId, so it was routed to the root session, did not match any callback there and got dropped, and the command hung forever.
  • Dispose worker sessions along with their frame session.

Fixes #42278

Messages addressed to a session that no longer exists in the browser are
answered with a -32001 error that has no sessionId, so it was routed to the
root session, did not match any callback there and got dropped. The pending
command was never resolved, e.g. context.unrouteAll() hung forever.

Route such errors by the message id and reject the command as closed. Also
dispose worker sessions when their frame session is disposed, otherwise a
worker of a detached oopif is never removed and we keep talking to it.

Fixes: microsoft#42278
- hoist the message id check into the caller, so the helpers take a number
- look up the session without allocating an array
- drop the redundant worker session key copy in FrameSession.dispose
- assert that an oopif is actually created in the new tests
@pavelfeldman

Copy link
Copy Markdown
Member

Routing replies to different session seems weird - these callbacks are unexpected there

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Disposing worker sessions in FrameSession.dispose is enough for the reported
hang: Target.detachedFromTarget for the oopif arrives before the pending
command, and disposing the worker session rejects it. Bring the connection
side back when there is a scenario that needs it.
@yury-s Yury Semikhatsky (yury-s) changed the title fix(chromium): unrouteAll hangs when a session is gone in the browser fix(chromium): dispose worker sessions when their frame session is disposed Aug 17, 2026
@github-actions

This comment has been minimized.

@yury-s

Copy link
Copy Markdown
Member Author

Routing replies to different session seems weird - these callbacks are unexpected there

Updated. Working with just child worker session removal along with oopif closure.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [firefox] › mcp/cli-drag.spec.ts:53 › drop files and data onto an element @mcp-windows-latest-firefox

8100 passed, 1311 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

21 flaky ⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@frozen-time-library-chromium-linux`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@frozen-time-library-chromium-linux`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/popup.spec.ts:260 › should not throw when click closes popup `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/chromium/chromium.spec.ts:301 › should report intercepted service worker requests in HAR `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/beforeunload.spec.ts:130 › should support dismissing the dialog multiple times `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/global-fetch.spec.ts:293 › should return security details from response `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/har.spec.ts:639 › should have security details `@chromium-ubuntu-22.04-node22`
⚠️ [chromium-library] › library/video.spec.ts:495 › screencast › should capture static page in persistent context Radoslav Kirilov (@smoke) `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/global-fetch.spec.ts:293 › should return security details from response `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/har.spec.ts:639 › should have security details `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-goto.spec.ts:90 › should work with Cross-Origin-Opener-Policy `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/global-fetch.spec.ts:293 › should return security details from response `@webkit-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/har.spec.ts:639 › should have security details `@webkit-ubuntu-22.04-node20`

51130 passed, 1226 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot and I took a look at the CI failures here.

🟢 CI is clear — the one failure is a pre-existing flake

The only real failure is mcp/cli-drag.spec.ts:53 on Firefox/Windows, and it's an unrelated flake. This PR is Chromium-only, so it can't reach it.

Details

Latest reports: "tests 1" is green (21 flaky, 0 failed) and "MCP" has a single failure. The earlier cancelled-status reports are truncated and carry no real failures. So there's exactly one failure to triage.

Pre-existing flake / infra

  • [firefox] › mcp/cli-drag.spec.ts:53 › drop files and data onto an element (mcp-windows-latest-firefox) — pre-existing flake. In the test-results DB this test on that bot failed 2 of 558 runs (~0.4%), passed the other 556, and both failures were on main push runs (shas 10c9602c and c973356e) with no PR attached — nowhere this branch could be responsible. This PR touches only crPage.ts::FrameSession (disposing Chromium worker sessions) and a Chromium oopif.spec.ts test; the Firefox MCP drag flow shares no code path with it.

Triaged by the Playwright bot - agent run

@yury-s
Yury Semikhatsky (yury-s) merged commit cf107fc into microsoft:main Aug 17, 2026
44 of 45 checks passed
@yury-s
Yury Semikhatsky (yury-s) deleted the fix-42278 branch August 17, 2026 21:37
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]: context.unrouteAll hanging

2 participants