fix browser click timeouts for existing-session routes#63524
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f63e14870
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const callPromise = session.client.callTool({ | ||
| name, | ||
| arguments: args, | ||
| }) as Promise<ChromeMcpToolResult>; |
There was a problem hiding this comment.
Skip MCP click call when request signal is already aborted
This path still invokes session.client.callTool(...) even when opts.signal.aborted is already true, because the abort branch only rejects abortPromise and does not return before creating callPromise. For side-effecting tools like click, a canceled request can still execute the browser action and mutate page state after the caller has timed out/canceled. This is reachable with pre-aborted dispatch signals (for example, an upstream abort propagated into route dispatch), so cancellation is not reliably honored.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 33864003ae4cf20c4a52e17258c4b35afa84aaf5. chrome-mcp.ts now short-circuits before creating session.client.callTool(...) when the signal is already aborted, and it re-checks after listener registration so pre-aborted requests cannot execute a side-effecting MCP click.
Greptile SummaryThis PR adds click timeout and abort-signal propagation for the Chrome MCP existing-session path: However, the PR also removes Confidence Score: 4/5Not safe to merge as-is: the SSRF post-click navigation guard for the Playwright browser path was inadvertently removed. The existing-session click timeout fix is correct and well-tested. However, the large deletion in
|
2f63e14 to
3386400
Compare
|
Addressed the review follow-ups in 33864003ae4cf20c4a52e17258c4b35afa84aaf5. The rebase onto current |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33864003ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await awaitEvalWithAbort( | ||
| locator.click({ | ||
| timeout, |
There was a problem hiding this comment.
Prevent click dispatch after abort during delayed clicks
If delayMs is non-zero and the request aborts during the setTimeout delay, abortPromise is already rejected but this code still evaluates locator.click(...) (and similarly locator.dblclick(...) above) before awaitEvalWithAbort runs the race. Because function arguments are evaluated eagerly, the click command can still be sent to Playwright after cancellation, so a timed-out/canceled request may still mutate page state. Race the delay itself against the abort signal (or re-check abort) before constructing the click promise.
Useful? React with 👍 / 👎.
3386400 to
ff0ad18
Compare
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <[email protected]>
ff0ad18 to
aadd692
Compare
|
Landed via rebase onto latest main.\n\nGate before merge:\n- pnpm test extensions/browser/src/browser/chrome-mcp.test.ts extensions/browser/src/browser/routes/agent.existing-session.test.ts extensions/browser/src/browser/pw-tools-core.interactions.evaluate.abort.test.ts: 25 passed\n- pnpm check:changed: 80 files / 717 tests passed\n- note: one prior changed-gate run hit a transient chrome.test.ts diagnostic race; rerun of extensions/browser/src/browser/chrome.test.ts passed 27/27, then final pnpm check:changed passed\n\nLand commit: aadd692\nMerge commit: e92079b\n\nThanks @dongseok0! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aadd69245f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (signal) { | ||
| racers.push( | ||
| new Promise<never>((_, reject) => { | ||
| abortListener = () => reject(signal.reason ?? new Error("aborted")); | ||
| signal.addEventListener("abort", abortListener, { once: true }); |
There was a problem hiding this comment.
Re-check abort after wiring Chrome MCP abort listener
After the initial signal.aborted guard, rawCall is started and the abort listener is attached, but there is no second aborted check after addEventListener. If the signal flips to aborted in that small window, the abort event can be missed and Promise.race will wait on rawCall/timeout instead of canceling, so a canceled click may still execute and mutate page state. This is the same race pattern already handled in clickViaPlaywright (with a post-registration check) and should be mirrored here.
Useful? React with 👍 / 👎.
Summary
Fixes #57158
Test Plan