Prevent reruns from inheriting stale browser harness state#425
Merged
Conversation
Rerun keeps the app session id while replacing the assigned CDP target. The harness REPL was keyed only by app session id, so reruns could reuse a long-lived browser-harness-js process that still held CDP state for the prior target. Scope the deterministic REPL port by target id as well as session id, and make the stock REPL reconnect if an existing CDP socket cannot attach to the assigned target. Constraint: Rerun reuses the app session id but creates a replacement browser target Rejected: Kill all harness REPL processes on rerun | broader lifecycle churn and could affect unrelated active sessions Confidence: high Scope-risk: narrow Directive: Keep Browser Harness JS REPL identity aligned with the assigned target when target lifecycle changes Tested: yarn test --run tests/unit/hl/browserHarnessEnv.test.ts Tested: yarn test --run tests/unit/hl Tested: yarn typecheck Tested: yarn lint Tested: yarn test Not-tested: Live Electron rerun from this worktree
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.
Rerun keeps the app session id while replacing the assigned CDP target. The harness REPL was keyed only by app session id, so reruns could reuse a long-lived browser-harness-js process that still held CDP state for the prior target.
Scope the deterministic REPL port by target id as well as session id, and make the stock REPL reconnect if an existing CDP socket cannot attach to the assigned target.
Constraint: Rerun reuses the app session id but creates a replacement browser target
Rejected: Kill all harness REPL processes on rerun | broader lifecycle churn and could affect unrelated active sessions
Confidence: high
Scope-risk: narrow
Directive: Keep Browser Harness JS REPL identity aligned with the assigned target when target lifecycle changes
Tested: yarn test --run tests/unit/hl/browserHarnessEnv.test.ts
Tested: yarn test --run tests/unit/hl
Tested: yarn typecheck
Tested: yarn lint
Tested: yarn test
Not-tested: Live Electron rerun from this worktree
Summary by cubic
Prevents reruns from inheriting stale CDP state by scoping the browser-harness REPL to the target and reconnecting when attach fails. Keeps the REPL aligned with the active target across reruns.
sessionId:targetIdandapplyBrowserHarnessEnvsetsCDP_REPL_PORTwithctx.targetId.session.use(targetId)fails, the stock REPL closes the socket and reconnects to the assigned target.Sessionsocket lifecycle: ignore messages from stale sockets, clear state on close, and reject pending requests on teardown.Written for commit 9506969. Summary will update on new commits.