Repository navigation
fix: don't throw if Dialog was handled - #2437
Merged
Merged
Conversation
OrKoN
approved these changes
Jul 29, 2026
Lightning00Blade
enabled auto-merge
July 29, 2026 11:28
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Jul 29, 2026
Lightning00Blade
force-pushed
the
fix-dialog-handling
branch
from
July 29, 2026 13:43
950dd82 to
a5bd7cc
Compare
Lightning00Blade
enabled auto-merge
July 29, 2026 13:43
OrKoN
pushed a commit
to LuHuangMSFT/chrome-devtools-mcp
that referenced
this pull request
Aug 10, 2026
🤖 I have created a release *beep* *boop* --- ## [1.7.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.6.0...chrome-devtools-mcp-v1.7.0) (2026-08-10) ### 🎉 Features * add a utility function to check for localhost. ([ChromeDevTools#2454](ChromeDevTools#2454)) ([c5ebf9e](ChromeDevTools@c5ebf9e)) * Add get_heapsnapshot_object_details MCP tool ([ChromeDevTools#2374](ChromeDevTools#2374)) ([8432cb9](ChromeDevTools@8432cb9)) * Emit native contexts in snapshot summary ([ChromeDevTools#2375](ChromeDevTools#2375)) ([f78a911](ChromeDevTools@f78a911)) * Filter heap snapshot objects by native context ([ChromeDevTools#2377](ChromeDevTools#2377)) ([76fd242](ChromeDevTools@76fd242)) * **telemetry:** log devtools data. ([ChromeDevTools#2460](ChromeDevTools#2460)) ([df2c753](ChromeDevTools@df2c753)) * **telemetry:** log is_devtools_open with each tool call. ([ChromeDevTools#2445](ChromeDevTools#2445)) ([6f60eab](ChromeDevTools@6f60eab)) * **telemetry:** report whether tool call is made on localhost. ([ChromeDevTools#2455](ChromeDevTools#2455)) ([6398b7e](ChromeDevTools@6398b7e)) * update lighthouse to 13.4.1 ([ChromeDevTools#2398](ChromeDevTools#2398)) ([745ffe7](ChromeDevTools@745ffe7)) ### 🛠️ Fixes * bound per-navigation network request retention ([ChromeDevTools#2435](ChromeDevTools#2435)) ([b08c73c](ChromeDevTools@b08c73c)) * **cli:** validate session ids ([ChromeDevTools#2475](ChromeDevTools#2475)) ([5ca9121](ChromeDevTools@5ca9121)) * **cli:** warn about version mismatch between cli and daemon ([ChromeDevTools#2461](ChromeDevTools#2461)) ([3afc44d](ChromeDevTools@3afc44d)) * **daemon:** preserve hyphenated browser flags in arg serialization and lazy daemon startup ([ChromeDevTools#2405](ChromeDevTools#2405)) ([d79f3ba](ChromeDevTools@d79f3ba)) * dispose heap snapshot workers on context teardown ([ChromeDevTools#2428](ChromeDevTools#2428)) ([f245c76](ChromeDevTools@f245c76)) * do not throw synchronously when a CDP session is gone ([ChromeDevTools#2466](ChromeDevTools#2466)) ([ba4fe3e](ChromeDevTools@ba4fe3e)) * don't throw if Dialog was handled ([ChromeDevTools#2437](ChromeDevTools#2437)) ([574c320](ChromeDevTools@574c320)) * downscale viewport screenshots when no viewport is emulated ([ChromeDevTools#2380](ChromeDevTools#2380)) ([39c4140](ChromeDevTools@39c4140)) * improve daemon lifecycle ([ChromeDevTools#2360](ChromeDevTools#2360)) ([3ee6a27](ChromeDevTools@3ee6a27)) * improve file writing ([ChromeDevTools#2447](ChromeDevTools#2447)) ([1da4bb0](ChromeDevTools@1da4bb0)) * include the tab id in `get_tab_id`'s text response ([ChromeDevTools#2381](ChromeDevTools#2381)) ([dcbaf49](ChromeDevTools@dcbaf49)) * **memory:** dispose the heap-snapshot worker when loading fails ([ChromeDevTools#2449](ChromeDevTools#2449)) ([744738d](ChromeDevTools@744738d)) * **performance:** reset trace-running flag when start_trace setup fails ([ChromeDevTools#2420](ChromeDevTools#2420)) ([40240c0](ChromeDevTools@40240c0)) * regression after the [ChromeDevTools#2443](ChromeDevTools#2443) ([ChromeDevTools#2462](ChromeDevTools#2462)) ([4c80ce4](ChromeDevTools@4c80ce4)) * rename maxRetainedSize column ([ChromeDevTools#2402](ChromeDevTools#2402)) ([75c7048](ChromeDevTools@75c7048)) * **screenshot:** dispose element handle after take_screenshot ([ChromeDevTools#2422](ChromeDevTools#2422)) ([fffb40e](ChromeDevTools@fffb40e)) * toggle lazy loading for source maps. ([ChromeDevTools#2486](ChromeDevTools#2486)) ([8028bfe](ChromeDevTools@8028bfe)) * **wait:** avoid 180s mutex stall when a dialog opens during an action ([ChromeDevTools#2427](ChromeDevTools#2427)) ([b4e8f74](ChromeDevTools@b4e8f74)) ### 📄 Documentation * Add devin cli install instruction to README ([ChromeDevTools#2361](ChromeDevTools#2361)) ([45262c0](ChromeDevTools@45262c0)) * correct the user data directory documentation ([ChromeDevTools#2473](ChromeDevTools#2473)) ([5ddbffd](ChromeDevTools@5ddbffd)) * **skills:** update memory leak debugging skill to use native MCP tools ([ChromeDevTools#2436](ChromeDevTools#2436)) ([99bd90a](ChromeDevTools@99bd90a)) * Update Chrome requirement for categoryExperimentalWebmcp ([ChromeDevTools#2163](ChromeDevTools#2163)) ([354458e](ChromeDevTools@354458e)) * update security.md ([ChromeDevTools#2362](ChromeDevTools#2362)) ([5012b07](ChromeDevTools@5012b07)) ### 🏗️ Refactor * clean up McpResponse.handle ([ChromeDevTools#2392](ChromeDevTools#2392)) ([348975d](ChromeDevTools@348975d)) * introduce Explicit resouce managent (using) ([ChromeDevTools#2443](ChromeDevTools#2443)) ([5b25370](ChromeDevTools@5b25370)) * move tool groups ([ChromeDevTools#2365](ChromeDevTools#2365)) ([2d944f9](ChromeDevTools@2d944f9)) * re-use Puppteer Mutex ([ChromeDevTools#2444](ChromeDevTools#2444)) ([775ea2d](ChromeDevTools@775ea2d)) * rename methods for clarity ([ChromeDevTools#2442](ChromeDevTools#2442)) ([dc23bcd](ChromeDevTools@dc23bcd)) * use a destructor to shorten the calls ([ChromeDevTools#2376](ChromeDevTools#2376)) ([77e1d3f](ChromeDevTools@77e1d3f)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
twotnguyen
pushed a commit
to twotnguyen/chrome-devtools-mcp
that referenced
this pull request
Oct 16, 2026
Fixes ChromeDevTools#2936 ## Problem When a dialog is already open on the page, `evaluate_script` does not fail fast like other `blockedByDialog: true` tools. It waits for the CDP protocol timeout (180 s) and holds the tool lock the whole time, so every other tool call is queued behind it. Root cause: `evaluate_script` is defined with `defineTool` (not `definePageTool`) because it can also target a service worker. `ToolHandler` runs `page.throwIfDialogOpen()` only in the page-scoped branch, so the `blockedByDialog: true` flag on `evaluate_script` has no effect. It is the only non-page-scoped tool with that flag. The check was originally applied to all tools (ChromeDevTools#1978) and was later limited to page-scoped tools in ChromeDevTools#2030, so that non-page tools do not have to resolve a page. ## Behavior change Before this change, `evaluate_script` could still run while a dialog that was already open and recorded on the page (for example one opened by a timer, as in the last part of ChromeDevTools#2936) was showing. It now returns `A dialog is open (...)` in that case, and `handle_dialog` is the way forward. ## Fix In the page path of the `evaluate_script` handler, call `mcpPage.throwIfDialogOpen()` after the target page is resolved and before any evaluation. `blockedByDialog` is now `false` on `evaluate_script`, because the flag has no effect on a `defineTool` tool, and `ToolDefinition` and `BrowserlessToolDefinition` narrow `blockedByDialog` to `false`, so the compiler rejects `true` on any non-page tool (`PageToolDefinition` keeps `boolean`). The call now fails with the same `A dialog is open (<type>: <message>).` error as other blocked tools. - `ToolHandler` is unchanged, so non-page tools still do not need a page (the ChromeDevTools#2030 behavior is kept). A generic check there would also have to tell the page path from the `serviceWorkerId` path, and would block worker evaluations that a page dialog does not affect, so the check lives in the handler where the target page is already resolved. - The service worker path is unchanged, because a page dialog does not block a worker. - The error response is the bare `A dialog is open (...)` error. Unlike page-scoped tools, it does not include the `# Open dialog ... Call handle_dialog` hint, because `ToolHandler` only attaches the page to the response for page-scoped tools. A TODO in `script.ts` tracks adding the hint once `Response` can attach the page for non-page-scoped tools. - `throwIfDialogOpen()` ignores dialogs that were already handled (ChromeDevTools#2437), so a dialog that `evaluate_script` auto-handled through `dialogAction` does not block later calls. - A dialog that opens during the script is still handled per `dialogAction`. ## Tests - `tests/tools/script.test.ts`: a mock-based handler test. When `throwIfDialogOpen` throws, the handler rejects with that error and never calls `waitForEventsAfterAction`. - `tests/index.test.ts` (e2e, Dialogs): a click opens an alert, then `evaluate_script` returns `isError` with `A dialog is open (alert: test dialog).`. ## Verification - With the issue's scenario against a local build, `main` returned `Runtime.evaluate timed out ...` after 180008 ms. With this change it returns `Error: A dialog is open (alert: hello alert).` in 4 ms. - Both new tests fail when the fix is reverted. The e2e test hits a client request timeout, and the handler test reports `Missing expected rejection`. - `tests/ToolHandler.test.ts`, `tests/tools/script.test.ts`, `tests/McpPage.test.ts` and `tests/index.test.ts` pass, along with `npm run build`, eslint and prettier on the changed files.
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.
Fixes #2424
Puppeteer now exposes
handledproperty on the Dialog. This will mean we can safely handle if from anywhere.package-lock.jsonchanges are fromnpm audit fix