fix(browser): recover stale CDP sessions#112
Open
MagMueller wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A flattened CDP target session can disappear while the browser-level WebSocket and page target remain usable. Reopening the root socket does not repair that target session, and an obsolete socket can still reject calls owned by a replacement socket.
Recovery also must not replay an arbitrary command on a different page. A rejected click, navigation, or evaluation is safe to retry only after reattaching the exact original target.
Change
connect()as ensure-connected, preserving a healthy socket and active target.-32001, serialize recovery, list targets at browser level, and reattach the exact original page.Reproduction
The tests use a local synthetic CDP WebSocket:
page-1and returnsession-1.CDP -32001: Session with given id not found.page-1inTarget.getTargets.page-1, domain restoration, and one successful retry.A second case removes
page-1before recovery and verifies that a side-effecting command is sent only once, no blank page is created, and no other target receives the command.Validation
bun testinpackages/bcode-browser: 21 pass, 8 environment-gated skipsbun typecheckinpackages/bcode-browsergit diff --check