Skip to content

fix: leave unbound guids in event payloads untouched instead of closing the connection - #642

Merged
mxschmitt merged 1 commit into
mxschmitt:mainfrom
Holocron-Technologies:upstream/cdp-event-unknown-guid-passthrough
Sep 14, 2026
Merged

mxschmitt merged 1 commit into
mxschmitt:mainfrom
Holocron-Technologies:upstream/cdp-event-unknown-guid-passthrough

Conversation

@pcockrill

Copy link
Copy Markdown
Contributor

Problem

Since the guid-resolution rewrite, connection.Dispatch treats any map carrying a guid key inside event params as a reference to a bound protocol object, and if the lookup fails it calls cleanup(...) on the whole connection. From then on every call on that Playwright instance fails with target closed: failed to resolve event parameters for event: failed to resolve map key 'params': object with guid <uuid> was not bound in the connection.

Raw CDP payloads relayed through CDPSession (event with {method, params}) legitimately contain such keys: Chrome's Page.downloadWillBegin and Page.downloadProgress carry a guid that names a download, not a Playwright object. So the first download seen by any page with a CDPSession that has Page.enabled permanently kills the process's driver connection.

Reproduction (v0.5700.1, stock driver): NewCDPSession(page) → Page.enable → Page.setDownloadBehavior allow → page.Goto(url that serves Content-Disposition: attachment). Afterwards browser.NewContext() and even pw.Chromium.Launch() return the error above.

Fix

Mirror the reference JS client (_replaceGuidsWithChannels): a guid that names a bound object resolves to its channel; any other guid value is plain data and the map is walked like every other map. This is also how playwright-go behaved before the rewrite (v0.5200.0 never errored here).

Two unit tests drive Dispatch directly: one asserts an unbound download guid reaches the event listener intact and the connection stays open; the other asserts bound guids (top-level and nested in a slice) still resolve to channels.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Uotgs1HWeELTqn9fLggWoH

@cursor

cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown

Follow-up I wanted on this branch: a live Chromium regression (TestCDPSessionDownloadDoesNotCloseConnection in tests/cdp_session_test.go) that does NewCDPSession + Page.enable + Page.setDownloadBehavior + a real attachment download, then asserts browser.NewContext() still works.

I could not push it here — cursor[bot] gets 403 on Holocron-Technologies/playwright-go even with maintainer edits allowed. The unit tests in this PR already cover the walk; the live test passed locally on this fix. Happy to land it in a follow-up after merge.

Bugbot on the branch (fix + that test) found no bugs. The change LGTM.

@mxschmitt
mxschmitt merged commit 3c0186f into mxschmitt:main Sep 14, 2026
22 checks passed
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.

2 participants