Repository navigation
fix(browser): preserve contextless worker and iframe sessions - #133571
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 5:51 PM ET / 21:51 UTC. ClawSweeper reviewWhat this changesThe PR forwards contextless worker and iframe CDP attachments with an outer parent session to Playwright while retaining safe release of contextless browser-root targets. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep this active: it is the linked maintainer-authored repair for a current browser-transport defect, and the introduced predicate plus boundary regression are coherent. No blocking patch defect surfaced; exact-head CI is still in progress. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s browser plugin connects to Chrome through a managed CDP WebSocket transport before handing events to Playwright. The transport must release unsupported contextless root targets but preserve nested session events for Playwright to manage. flowchart LR
A[Chrome CDP attachment] --> B[Managed browser transport]
B --> C{Outer parent session?}
C -->|Yes| D[Playwright nested session]
C -->|No| E{Contextless root target?}
E -->|Yes| F[Resume then detach]
E -->|No| G[Playwright browser handler]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1, Tests +26. Total +27 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the narrow transport-owner distinction after exact-head checks complete, preserving root-target protection while leaving parent-routed sessions to Playwright. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible with high confidence: current main’s predicate releases a contextless attachment based only on target information, while the focused WebSocket scenario supplies an outer parent session and observes the lost event path. Is this the best way to solve the issue? Yes. The outer session ID is the narrow ownership discriminator at the transport boundary; a target-type allowlist would miss valid siblings, while removing root release would undo the existing crash protection. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 786b19ebfbb5. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready verification for a2d28d32c9ac798b0f0cd4b75ea5126e4f44200b: exact-head CI run 33337277959 succeeded, the required All items in the latest ClawSweeper review are addressed:
The transport owns root-target interception; Playwright owns parent-routed child sessions. The existing predicate is the right repair point, not a type allowlist or downstream workaround. Root resume-response-before-detach, internal reply suppression, DNS pinning and lifecycle cleanup remain intact. No old path was retained or added. Production is +3/-2 (net +1); tests are +39/-13 (net +26). Local proof: the new four nested-event cases failed before the repair; the final 96/96 sibling tests and complete changed-scope gate passed: node scripts/run-vitest.mjs extensions/browser/src/browser/pw-session.pinned-transport.test.ts extensions/browser/src/browser/pw-session.connections.test.ts extensions/browser/src/browser/pw-session.enumeration.test.ts extensions/browser/src/browser/pw-session.termination-cdp-ssrf.test.ts extensions/browser/src/browser/cdp.helpers.internal.test.ts extensions/browser/src/browser/cdp.helpers.transport.test.tsnode scripts/check-changed.mjs -- extensions/browser/src/browser/pw-session-cdp-transport.ts extensions/browser/src/browser/pw-session.pinned-transport.test.tsFresh Codex autoreview was Proceeding through the native hosted-CI prepare/merge flow; this closes the nested-attachment bug in #133569. |
|
Merged via squash.
|
* origin/main: (55 commits) test: include v2026.8.1 release navigation (#133581) fix: stop cloud work before unrelated provider inspection finishes (#133476) fix(e2e): keep delete fixture target-compatible (#133526) fix(release): detect optional target E2E capability (#133525) fix(package): publish readable dist inventory (#133549) docs: add complete v2026.8.1 maintainer change index (#133585) fix(browser): preserve contextless worker and iframe sessions (#133571) fix(voice): discover configured provider candidates (#133507) refactor(ui): simplify chat rendering and lifecycle state (#133567) test: reduce maturity fixture cleanup time (#133566) improve: speed up legacy imports and transcript replacement (#133546) docs: add draft v2026.8.1 release notes (#133557) test: guard multi-project Vitest cache ownership (#133554) fix(memory): clarify default agent scope in command help (#133560) fix(clawdock): keep credentials out of diagnostic output (#133547) refactor(ui): avoid redundant presence work in avatar lists (#133548) fix(agents): recognize internal requester completion replies (#133543) fix: prevent duplicate queued user messages in chat clients (#133542) chore(ui): refresh control ui locales (#133544) fix(beam): restart delivery when the receiver changes (#133533) ...
…cked-delivery * origin/main: test: include v2026.8.1 release navigation (openclaw#133581) fix: stop cloud work before unrelated provider inspection finishes (openclaw#133476) fix(e2e): keep delete fixture target-compatible (openclaw#133526) fix(release): detect optional target E2E capability (openclaw#133525) fix(package): publish readable dist inventory (openclaw#133549) docs: add complete v2026.8.1 maintainer change index (openclaw#133585) fix(browser): preserve contextless worker and iframe sessions (openclaw#133571) fix(voice): discover configured provider candidates (openclaw#133507) refactor(ui): simplify chat rendering and lifecycle state (openclaw#133567) test: reduce maturity fixture cleanup time (openclaw#133566) improve: speed up legacy imports and transcript replacement (openclaw#133546) docs: add draft v2026.8.1 release notes (openclaw#133557) test: guard multi-project Vitest cache ownership (openclaw#133554) fix(memory): clarify default agent scope in command help (openclaw#133560)
Closes #133569
Related: #132419 — root contextless-target crash protection.
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.
What Problem This Solves
Fixes an issue where browser automation loses nested workers and out-of-process iframes when their CDP attachment event has a parent session but omits
browserContextId. Playwright never receives those events because the managed transport incorrectly treats them as browser-root targets.This is a pre-existing main defect, not a regression introduced by the standalone relay feature. The affected modules remain unchanged on main
00b64b81c4073e594c423bcb5e7a5ca1c5a6f6d7.Why This Change Was Made
Only Playwright's browser-root attachment handler requires
browserContextId. The outer envelopesessionIdselects the parent session;params.sessionIdidentifies the attached child. Add that missing discriminator to the existing predicate so every parent-routed attachment passes through unchanged, while the root-only protection remains intact.Root contextless targets still resume, wait for the resume response, and then detach. DNS pinning, endpoint discovery, internal reply suppression, and connection/event cleanup are unchanged. No new configuration, dependencies, compatibility path, public API, or test-only production seam.
User Impact
Playwright retains ownership of nested worker and iframe sessions even when the optional context field is absent. Existing protection against contextless root targets terminating the Gateway is preserved.
Evidence
Before and after
The regression uses the actual managed WebSocket transport through
listPagesViaPlaywright, with a mock only at the Playwright consumer boundary. Before the production edit, all four nested worker/iframe envelopes (paused and unpaused) were missing; one test failed and the other six passed. After repair, all seven transport tests pass. The test also proves nine root resumes, no detach before a resume response, exactly one detach per resumed root session, unchanged forwarded envelopes, and no leaked internal replies or extra commands after socket closure.The final sibling run passed 96/96 tests across six files, covering pinning, cross-authority redirect rejection, connection retirement/cancellation, scoped cleanup, enumeration, and event-before-close delivery:
The complete changed-scope gate passed, including production/test typechecks, lint, formatting, five doctor-contract tests, export scans, boundary guards, and zero runtime import cycles:
Fresh Codex autoreview completed
scoped-cleanwith no P0 findings. An initial test-fixture conditional-spread lint finding was fixed and the full gate rerun successfully.Real dependency and browser proof
Personally inspected installed Playwright 1.62.1:
lib/coreBundle.js:34732–34738routes on the outer session ID;37547–37599handles nested worker/iframe attachments;38166–38201requires the context field only in the root handler.A disposable, isolated Chrome for Testing 151.0.7922.34 and real Playwright exercised the actual repaired transport. Ordinary traffic passed worker evaluation (
42), worker-to-page messaging, cross-site OOPIF content/evaluation (63), and positive Playwright-owned initialization/resume commands. Chromium naturally included context IDs, so a second explicitly fault-injected leg removed onlytargetInfo.browserContextIdfrom nested worker/iframe events. It passed the same assertions without transport-owned resume/detach commands. Every other envelope field and text framing were preserved.Scratch-fixture framing and startup-budget failures were corrected before the successful run; they were not product failures. The browser, WebSockets, ephemeral ports, and temporary profile were cleaned up. No operator Chrome/Gateway or parked relay work was used. This is dependency/transport proof, not a Gateway or extension-relay end-to-end claim; no UI or visual layout changes are included.
Scope and size
Production: +3/-2, net +1. The one added line is the session-ownership discriminator within the existing predicate. Tests: +39/-13, net +26, extending the existing table and making assertion failure/cleanup reliable rather than adding another fixture.
Release-note context: Browser automation now preserves nested worker and iframe CDP sessions that omit a browser context ID while retaining safe release of contextless root targets.