Skip to content

fix(agent): restore input blocker on Chrome fatal error#22574

Closed
cRAN-cg wants to merge 6 commits intogoogle-gemini:mainfrom
cRAN-cg:fix/restore-input-blocker-on-fatal-error
Closed

fix(agent): restore input blocker on Chrome fatal error#22574
cRAN-cg wants to merge 6 commits intogoogle-gemini:mainfrom
cRAN-cg:fix/restore-input-blocker-on-fatal-error

Conversation

@cRAN-cg
Copy link
Copy Markdown

@cRAN-cg cRAN-cg commented Mar 15, 2026

Summary

Fixes #22159

The McpToolInvocation.execute() method in mcpToolWrapper.ts had a bug where resumeInputBlocker() was never called when a fatal Chrome connection error ("Could not connect to Chrome") was thrown mid-execution of an interactive tool (click, fill, hover, etc.). This left the input blocker overlay permanently suspended (pointer-events: none), causing the tab to appear controlled but not actually blocking user input.

Changes

  • mcpToolWrapper.ts: Refactored the execute() method to use try...finally. suspendInputBlocker() is called before the try block (resource acquisition), and resumeInputBlocker() is called in the finally block with .catch(() => {}) to ensure cleanup on all code paths — success, non-fatal error, and fatal Chrome disconnection. This replaces the previous two separate resume call sites with a single one in finally.

  • mcpToolWrapper.test.ts: Added two new test cases:

    1. Chrome fatal error still resumes the input blocker via finally
    2. Chrome fatal error + resume failure (double fault) — original error propagates, resume failure is swallowed by .catch(() => {})

Test plan

  • Existing tests pass (suspend/resume on success, non-fatal error paths)
  • New test: fatal Chrome error resumes blocker
  • New test: fatal error + resume failure doesn't mask original error
  • Pre-commit hooks pass (prettier, eslint, lint-staged)
  • npm run preflight (CI will validate)

@cRAN-cg cRAN-cg requested a review from a team as a code owner March 15, 2026 22:36
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue where the browser's input blocker could remain permanently suspended following a fatal Chrome connection error during interactive tool execution. By restructuring the input blocker's resumption logic with a try...finally block, the system now reliably restores the blocker, significantly improving the robustness and user experience of interactive browser automation. Comprehensive new tests have been introduced to validate this fix under various error conditions.

Highlights

  • Input Blocker Resumption Logic: Refactored the McpToolInvocation.execute() method to use a try...finally block, ensuring resumeInputBlocker() is always called. This guarantees the input blocker is restored even during fatal Chrome connection errors, preventing the tab from remaining frozen.
  • Test Coverage Enhancement: Added two new test cases to mcpToolWrapper.test.ts to specifically cover scenarios where the input blocker is resumed after a fatal Chrome connection error, including cases where the resume operation itself might fail.
Changelog
  • packages/core/src/agents/browser/mcpToolWrapper.test.ts
    • Added a test case to verify that the input blocker resumes even when a fatal Chrome connection error is thrown.
    • Added a test case to confirm that the original fatal error propagates even if the blocker resumption itself fails.
  • packages/core/src/agents/browser/mcpToolWrapper.ts
    • Moved the suspendInputBlocker call to occur before the try block.
    • Removed redundant resumeInputBlocker calls from the success and error paths.
    • Introduced a finally block to ensure resumeInputBlocker is called on all execution paths, including when fatal errors are thrown.
Activity
  • Existing tests for suspend/resume on success and non-fatal error paths have passed.
  • New test cases for fatal Chrome errors and resume failures have been added and are passing.
  • Pre-commit hooks (prettier, eslint, lint-staged) have passed.
  • The pull request is awaiting CI validation (npm run preflight).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue where the input blocker was not restored after a fatal Chrome connection error. The change refactors mcpToolWrapper.ts to use a try...finally block, ensuring resumeInputBlocker is called on all execution paths. New test cases have been added to mcpToolWrapper.test.ts to verify this behavior, including handling of fatal errors and double-fault scenarios where the resume action also fails. The changes appear correct and address the described issue.

@cRAN-cg
Copy link
Copy Markdown
Author

cRAN-cg commented Mar 18, 2026

/assign

Refactor McpToolInvocation.execute() to use try...finally so that
resumeInputBlocker() is always called when the input blocker was
suspended, regardless of whether the tool succeeds or throws a fatal
Chrome connection error.

Previously, the "Could not connect to Chrome" error path re-threw
before resumeInputBlocker() could run, leaving the overlay permanently
stuck with pointer-events: none.

Also adds two test cases covering the fatal error path:
- Chrome fatal error still resumes the input blocker
- Chrome fatal error + resume failure (double fault) propagates
  the original error without masking

Fixes google-gemini#22159
@cRAN-cg cRAN-cg force-pushed the fix/restore-input-blocker-on-fatal-error branch from b6b44b2 to 26560be Compare March 21, 2026 05:05
@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli bot commented Mar 30, 2026

Hi there! Thank you for your interest in contributing to Gemini CLI.

To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383).

We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'.

This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community!

@gemini-cli gemini-cli bot closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agent Issues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Input blocker not restored when Chrome fatal error occurs in browser agent

1 participant